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 30, 2021
1 parent eaf4cba commit 30ee141
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 20 deletions.
10 changes: 6 additions & 4 deletions test/es-module/test-esm-export-not-found.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,11 @@ const importStatementMultiline = `import {
stderr += data;
});
child.on('close', () => {
ok(stderr.includes(
'SyntaxError: The requested module \'./module-named-exports.mjs\' ' +
'does not provide an export named \'notfound\''
));
// SyntaxError: The requested module './module-named-exports.mjs'
// does not provide an export named 'notfound'
ok(stderr.includes('SyntaxError:'));
// The quotes ensure that the path starts with ./ and not ../
ok(stderr.includes('\'./module-named-exports.mjs\''));
ok(stderr.includes('notfound'));
});
});
9 changes: 5 additions & 4 deletions test/es-module/test-esm-import-json-named-export.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ child.stderr.on('data', (data) => {
stderr += data;
});
child.on('close', () => {
ok(stderr.includes(
'SyntaxError: The requested module \'../experimental.json\' ' +
'does not provide an export named \'ofLife\''
));
// 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\''));
});
9 changes: 5 additions & 4 deletions test/es-module/test-esm-loader-not-found.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ child.stderr.on('data', (data) => {
stderr += data;
});
child.on('close', () => {
ok(stderr.includes(
'Error [ERR_MODULE_NOT_FOUND]: Cannot find package \'i-dont-exist\' ' +
'imported from'
));
// 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('Bad command or file name'));
});
4 changes: 1 addition & 3 deletions test/es-module/test-esm-loader-with-syntax-error.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ child.stderr.on('data', (data) => {
stderr += data;
});
child.on('close', () => {
ok(stderr.includes(
'SyntaxError: Malformed arrow function parameter list'
));
ok(stderr.includes('SyntaxError:'));
ok(!stderr.includes('Bad command or file name'));
});
5 changes: 3 additions & 2 deletions test/es-module/test-esm-module-not-found-commonjs-hint.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ import { execPath } from 'process';
[
{
input: 'import "./print-error-message"',
expected: 'Did you mean to import ../print-error-message.js?'
// Did you mean to import ../print-error-message.js?
expected: ' ../print-error-message.js?'
},
{
input: 'import obj from "some_module/obj"',
expected: 'Did you mean to import some_module/obj.js?'
expected: ' some_module/obj.js?'
},
].forEach(({ input, expected }) => {
const child = spawn(execPath, [
Expand Down
4 changes: 1 addition & 3 deletions test/es-module/test-esm-syntax-error.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,5 @@ child.stderr.on('data', (data) => {
stderr += data;
});
child.on('close', () => {
ok(stderr.includes(
'SyntaxError: Malformed arrow function parameter list'
));
ok(stderr.includes('SyntaxError:'));
});

0 comments on commit 30ee141

Please sign in to comment.