Skip to content

Commit 4ee996b

Browse files
committed
repair test
1 parent 81e5fb9 commit 4ee996b

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

test/es-module/test-typescript-commonjs.mjs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -68,19 +68,19 @@ test('expect failure of an .mts file with CommonJS syntax', async () => {
6868

6969
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.`;
7070

71-
// First assertion: check that stderr contains a generic pattern for the ES module load failure.
72-
// This ensures that at a minimum the error message structure is as expected.
73-
assert.match(
74-
result.stderr,
75-
/Failed to load the ES module:.*test-cts-but-module-syntax\.cts/
76-
);
77-
78-
// Second assertion: verify that stderr includes the complete expected warning message.
79-
// We use a try/catch here to improve the error output, providing more context if the assertion fails.
80-
// Having two assertions ensures that:
81-
// 1. We first confirm the error message follows the expected general format.
82-
// 2. We then check that the specific warning (with file path and message details) is present.
8371
try {
72+
// First assertion: check that stderr contains a generic pattern for the ES module load failure.
73+
// This ensures that at a minimum the error message structure is as expected.
74+
assert.match(
75+
result.stderr,
76+
/Failed to load the ES module:.*test-cts-but-module-syntax\.cts/
77+
);
78+
79+
// Second assertion: verify that stderr includes the complete expected warning message.
80+
// We use a try/catch here to improve the error output, providing more context if the assertion fails.
81+
// Having two assertions ensures that:
82+
// 1. We first confirm the error message follows the expected general format.
83+
// 2. We then check that the specific warning (with file path and message details) is present.
8484
assert.ok(
8585
result.stderr.includes(expectedWarning),
8686
`Expected stderr to include: ${expectedWarning}`

0 commit comments

Comments
 (0)