Skip to content

Commit a60b3e0

Browse files
committed
undo a test that has been erased
1 parent 2b3000c commit a60b3e0

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

test/es-module/test-esm-detect-ambiguous.mjs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,3 +426,24 @@ describe('when working with Worker threads', () => {
426426
strictEqual(signal, null);
427427
});
428428
});
429+
430+
describe('cjs & esm ambiguous syntax case', () => {
431+
it('should throw an ambiguous syntax error when using top-level await with require', async () => {
432+
const { stderr, code, signal } = await spawnPromisified(
433+
process.execPath,
434+
[
435+
'--input-type=module',
436+
'--eval',
437+
`await 1;\nconst fs = require('fs');`,
438+
]
439+
);
440+
441+
match(
442+
stderr,
443+
/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\./
444+
);
445+
446+
strictEqual(code, 1);
447+
strictEqual(signal, null);
448+
});
449+
});

0 commit comments

Comments
 (0)