Skip to content

Commit

Permalink
fixup! esm: refactor esm tests out of test/message
Browse files Browse the repository at this point in the history
  • Loading branch information
GeoffreyBooth committed Dec 31, 2021
1 parent 321b151 commit 8548e52
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 14 deletions.
7 changes: 4 additions & 3 deletions test/es-module/test-esm-export-not-found.mjs
Expand Up @@ -30,9 +30,10 @@ const importStatementMultiline = `import {
child.on('close', () => {
// SyntaxError: The requested module './module-named-exports.mjs'
// does not provide an export named 'notfound'
ok(stderr.includes('SyntaxError:'));
ok(stderr.includes('SyntaxError:') || console.error(stderr));
// The quotes ensure that the path starts with ./ and not ../
ok(stderr.includes('\'./module-named-exports.mjs\''));
ok(stderr.includes('notfound'));
ok(stderr.includes('\'./module-named-exports.mjs\'') ||
console.error(stderr));
ok(stderr.includes('notfound') || console.error(stderr));
});
});
6 changes: 3 additions & 3 deletions test/es-module/test-esm-import-json-named-export.mjs
Expand Up @@ -17,7 +17,7 @@ child.stderr.on('data', (data) => {
child.on('close', () => {
// SyntaxError: The requested module '../experimental.json'
// does not provide an export named 'ofLife'
ok(stderr.includes('SyntaxError:'));
ok(stderr.includes('\'../experimental.json\''));
ok(stderr.includes('\'ofLife\''));
ok(stderr.includes('SyntaxError:') || console.error(stderr));
ok(stderr.includes('\'../experimental.json\'') || console.error(stderr));
ok(stderr.includes('\'ofLife\'') || console.error(stderr));
});
6 changes: 3 additions & 3 deletions test/es-module/test-esm-loader-not-found.mjs
Expand Up @@ -18,8 +18,8 @@ child.stderr.on('data', (data) => {
child.on('close', () => {
// Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'i-dont-exist'
// imported from
ok(stderr.includes('ERR_MODULE_NOT_FOUND'));
ok(stderr.includes('\'i-dont-exist\''));
ok(stderr.includes('ERR_MODULE_NOT_FOUND') || console.error(stderr));
ok(stderr.includes('\'i-dont-exist\'') || console.error(stderr));

ok(!stderr.includes('Bad command or file name'));
ok(!stderr.includes('Bad command or file name') || console.error(stderr));
});
2 changes: 1 addition & 1 deletion test/es-module/test-esm-loader-obsolete-hooks.mjs
Expand Up @@ -21,5 +21,5 @@ child.on('close', () => {
ok(stderr.includes(
'DeprecationWarning: Obsolete loader hook(s) supplied and will be ' +
'ignored: dynamicInstantiate, getFormat, getSource, transformSource'
));
) || console.error(stderr));
});
4 changes: 2 additions & 2 deletions test/es-module/test-esm-loader-with-syntax-error.mjs
Expand Up @@ -16,6 +16,6 @@ child.stderr.on('data', (data) => {
stderr += data;
});
child.on('close', () => {
ok(stderr.includes('SyntaxError:'));
ok(!stderr.includes('Bad command or file name'));
ok(stderr.includes('SyntaxError:') || console.error(stderr));
ok(!stderr.includes('Bad command or file name') || console.error(stderr));
});
2 changes: 1 addition & 1 deletion test/es-module/test-esm-module-not-found-commonjs-hint.mjs
Expand Up @@ -29,6 +29,6 @@ import { execPath } from 'process';
stderr += data;
});
child.on('close', () => {
ok(stderr.includes(expected));
ok(stderr.includes(expected) || console.error(stderr));
});
});
2 changes: 1 addition & 1 deletion test/es-module/test-esm-syntax-error.mjs
Expand Up @@ -14,5 +14,5 @@ child.stderr.on('data', (data) => {
stderr += data;
});
child.on('close', () => {
ok(stderr.includes('SyntaxError:'));
ok(stderr.includes('SyntaxError:') || console.error(stderr));
});

0 comments on commit 8548e52

Please sign in to comment.