Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
undo a test that has been erased
  • Loading branch information
islandryu committed Jun 29, 2025
commit a60b3e04e120ffb71e02c78a7fe47daa748db203
21 changes: 21 additions & 0 deletions test/es-module/test-esm-detect-ambiguous.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -426,3 +426,24 @@ describe('when working with Worker threads', () => {
strictEqual(signal, null);
});
});

describe('cjs & esm ambiguous syntax case', () => {
it('should throw an ambiguous syntax error when using top-level await with require', async () => {
const { stderr, code, signal } = await spawnPromisified(
process.execPath,
[
'--input-type=module',
'--eval',
`await 1;\nconst fs = require('fs');`,
]
);

match(
stderr,
/ReferenceError: Cannot determine intended module format because both require\(\) and top-level await are present\. If the code is intended to be CommonJS, wrap await in an async function\. If the code is intended to be an ES module, replace require\(\) with import\./
);

strictEqual(code, 1);
strictEqual(signal, null);
});
});
Loading