Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
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
fixup! esm: refactor esm tests out of test/message
  • Loading branch information
GeoffreyBooth committed Jan 6, 2022
commit d64d044beb3ae715207625d5973e858f505fe768
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:'));
});