Skip to content
Merged
Changes from 1 commit
Commits
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
test
  • Loading branch information
Xstoudi committed Jan 2, 2026
commit 0e69c4da38bcbdf9b6ed5e1fae9e0e813542a6a6
47 changes: 47 additions & 0 deletions test/sequential/test-watch-mode.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -884,4 +884,51 @@
await done();
}
});

it('should watch changes even when there is syntax errors during esm loading', async () => {
Comment thread
Xstoudi marked this conversation as resolved.
Resolved
// Create initial file with valid code
const initialContent = `console.log('hello, world');`;
const file = createTmpFile(initialContent, '.mjs');

const { done, restart } = runInBackground({
args: ['--watch', file],
completed: 'Completed running',
shouldFail: true,
});

try {
Comment thread
marco-ippolito marked this conversation as resolved.
Resolved
const { stdout, stderr } = await restart();
assert.strictEqual(stderr, '');
assert.deepStrictEqual(stdout, [
'hello, world',
`Completed running ${inspect(file)}. Waiting for file changes before restarting...`,
])

Check failure on line 905 in test/sequential/test-watch-mode.mjs

View workflow job for this annotation

GitHub Actions / lint-js-and-md

Missing semicolon

// Update file with syntax error
const syntaxErrorContent = `console.log('hello, wor`;
writeFileSync(file, syntaxErrorContent);

// Wait for the failed restart
const { stderr: stderr2, stdout: stdout2 } = await restart();
assert.match(stderr2, /SyntaxError: Invalid or unexpected token/);
assert.deepStrictEqual(stdout2, [
`Restarting ${inspect(file)}`,
`Failed running ${inspect(file)}. Waiting for file changes before restarting...`,
])

Check failure on line 917 in test/sequential/test-watch-mode.mjs

View workflow job for this annotation

GitHub Actions / lint-js-and-md

Missing semicolon

writeFileSync(file, `console.log('hello again, world');`);

const { stderr: stderr3, stdout: stdout3 } = await restart();

// Verify it recovered and ran successfully
assert.strictEqual(stderr3, '');
assert.deepStrictEqual(stdout3, [
`Restarting ${inspect(file)}`,
'hello again, world',
`Completed running ${inspect(file)}. Waiting for file changes before restarting...`,
]);
} finally {
await done();
}
});
});
Loading