Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: improve watch mode test #50319

Merged
merged 3 commits into from Oct 23, 2023
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 7 additions & 6 deletions test/sequential/test-watch-mode.mjs
Expand Up @@ -62,7 +62,7 @@ async function runWriteSucceed({
child.kill();
cancelRestarts();
}
return { stdout, stderr };
return { stdout, stderr, pid: child.pid };
}

async function failWriteSucceed({ file, watchedFile }) {
Expand Down Expand Up @@ -259,7 +259,7 @@ console.log(values.random);
]);
});

it('should not load --require modules in main process', async () => {
it('should load --require modules in the watched process, and not in the orchestrator process', async () => {
const file = createTmpFile();
const required = createTmpFile('setImmediate(() => process.exit(0));');
const args = ['--require', required, file];
Expand All @@ -275,13 +275,14 @@ console.log(values.random);
]);
});

it('should not load --import modules in main process', async () => {
it('should load --import modules in the watched process, and not in the orchestrator process', async () => {
const file = createTmpFile();
const imported = pathToFileURL(createTmpFile('process._rawDebug("imported");'));
const imported = "data:text/javascript,process._rawDebug('pid', process.pid);";
const args = ['--import', imported, file];
const { stderr, stdout } = await runWriteSucceed({ file, watchedFile: file, args });
const { stdout, pid } = await runWriteSucceed({ file, watchedFile: file, args });

assert.strictEqual(stderr, 'imported\nimported\n');
const importPid = parseInt(stdout[0].split(' ')[1], 10);
assert.notStrictEqual(pid, importPid);
assert.deepStrictEqual(stdout, [
'running',
`Completed running ${inspect(file)}`,
Expand Down