Skip to content

Commit

Permalink
use regexp for CommonJS error
Browse files Browse the repository at this point in the history
  • Loading branch information
Mert Can Altin committed Feb 19, 2025
1 parent 1c133c9 commit 001a823
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion test/es-module/test-typescript-commonjs.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,13 @@ test('expect failure of an .mts file with CommonJS syntax', async () => {

const expectedWarning = `Failed to load the ES module: ${testFilePath}. Make sure to set "type": "module" in the nearest package.json file or use the .mjs extension.`;
try {
assert.ok(result.stderr.includes(expectedWarning));
assert.match(
result.stderr,
new RegExp(
`Failed to load the ES module: ${testFilePath}\\. Make sure to set "type": "module" in the nearest package\\.json file or use the \\.mjs extension\\.`
)
);

} catch (e) {
if (e?.code === 'ERR_ASSERTION') {
e.expected = expectedWarning;
Expand Down

0 comments on commit 001a823

Please sign in to comment.