Skip to content

Commit 8548e52

Browse files
committed
fixup! esm: refactor esm tests out of test/message
1 parent 321b151 commit 8548e52

7 files changed

+15
-14
lines changed

test/es-module/test-esm-export-not-found.mjs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,10 @@ const importStatementMultiline = `import {
3030
child.on('close', () => {
3131
// SyntaxError: The requested module './module-named-exports.mjs'
3232
// does not provide an export named 'notfound'
33-
ok(stderr.includes('SyntaxError:'));
33+
ok(stderr.includes('SyntaxError:') || console.error(stderr));
3434
// The quotes ensure that the path starts with ./ and not ../
35-
ok(stderr.includes('\'./module-named-exports.mjs\''));
36-
ok(stderr.includes('notfound'));
35+
ok(stderr.includes('\'./module-named-exports.mjs\'') ||
36+
console.error(stderr));
37+
ok(stderr.includes('notfound') || console.error(stderr));
3738
});
3839
});

test/es-module/test-esm-import-json-named-export.mjs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ child.stderr.on('data', (data) => {
1717
child.on('close', () => {
1818
// SyntaxError: The requested module '../experimental.json'
1919
// does not provide an export named 'ofLife'
20-
ok(stderr.includes('SyntaxError:'));
21-
ok(stderr.includes('\'../experimental.json\''));
22-
ok(stderr.includes('\'ofLife\''));
20+
ok(stderr.includes('SyntaxError:') || console.error(stderr));
21+
ok(stderr.includes('\'../experimental.json\'') || console.error(stderr));
22+
ok(stderr.includes('\'ofLife\'') || console.error(stderr));
2323
});

test/es-module/test-esm-loader-not-found.mjs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ child.stderr.on('data', (data) => {
1818
child.on('close', () => {
1919
// Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'i-dont-exist'
2020
// imported from
21-
ok(stderr.includes('ERR_MODULE_NOT_FOUND'));
22-
ok(stderr.includes('\'i-dont-exist\''));
21+
ok(stderr.includes('ERR_MODULE_NOT_FOUND') || console.error(stderr));
22+
ok(stderr.includes('\'i-dont-exist\'') || console.error(stderr));
2323

24-
ok(!stderr.includes('Bad command or file name'));
24+
ok(!stderr.includes('Bad command or file name') || console.error(stderr));
2525
});

test/es-module/test-esm-loader-obsolete-hooks.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,5 @@ child.on('close', () => {
2121
ok(stderr.includes(
2222
'DeprecationWarning: Obsolete loader hook(s) supplied and will be ' +
2323
'ignored: dynamicInstantiate, getFormat, getSource, transformSource'
24-
));
24+
) || console.error(stderr));
2525
});

test/es-module/test-esm-loader-with-syntax-error.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ child.stderr.on('data', (data) => {
1616
stderr += data;
1717
});
1818
child.on('close', () => {
19-
ok(stderr.includes('SyntaxError:'));
20-
ok(!stderr.includes('Bad command or file name'));
19+
ok(stderr.includes('SyntaxError:') || console.error(stderr));
20+
ok(!stderr.includes('Bad command or file name') || console.error(stderr));
2121
});

test/es-module/test-esm-module-not-found-commonjs-hint.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,6 @@ import { execPath } from 'process';
2929
stderr += data;
3030
});
3131
child.on('close', () => {
32-
ok(stderr.includes(expected));
32+
ok(stderr.includes(expected) || console.error(stderr));
3333
});
3434
});

test/es-module/test-esm-syntax-error.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@ child.stderr.on('data', (data) => {
1414
stderr += data;
1515
});
1616
child.on('close', () => {
17-
ok(stderr.includes('SyntaxError:'));
17+
ok(stderr.includes('SyntaxError:') || console.error(stderr));
1818
});

0 commit comments

Comments
 (0)