Skip to content

Commit 6248db4

Browse files
committed
test: relax execArgv watcher assertion
1 parent 85b98bb commit 6248db4

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

test/sequential/test-watch-mode-watch-flags.mjs

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,20 +105,35 @@ describe('watch mode - watch flags', { concurrency: !process.env.TEST_PARALLEL,
105105
const watchPath = path.join(projectDir, 'template.html');
106106
writeFileSync(watchPath, '');
107107

108-
async function assertExecArgv(args, expected) {
108+
async function assertExecArgv(args, expectedPrefixes) {
109109
const { stdout, stderr } = await runNode({
110110
args, options: { cwd: projectDir }
111111
});
112112

113113
assert.strictEqual(stderr, '');
114114

115115
const execArgvLine = stdout[0];
116-
assert.deepStrictEqual(JSON.parse(execArgvLine), expected);
116+
const execArgv = JSON.parse(execArgvLine);
117+
assert.ok(Array.isArray(execArgv));
118+
const matched = expectedPrefixes.some((expectedPrefix) => {
119+
if (execArgv.length < expectedPrefix.length) {
120+
return false;
121+
}
122+
return execArgv.slice(0, expectedPrefix.length)
123+
.every((value, idx) => value === expectedPrefix[idx]);
124+
});
125+
assert.ok(matched,
126+
`execArgv (${execArgv}) does not start with any expected prefix (${expectedPrefixes.map((p) => `[${p}]`).join(', ')})`);
117127
assert.match(stdout.at(-1), /^Completed running/);
118128
}
119129

120-
await assertExecArgv(['--watch', file], ['--watch']);
121-
await assertExecArgv(['--watch-path=template.html', file], ['--watch-path=template.html']);
122-
await assertExecArgv(['--watch-path', 'template.html', file], ['--watch-path', 'template.html']);
130+
await assertExecArgv(['--watch', file], [['--watch']]);
131+
await assertExecArgv(['--watch-path=template.html', file], [['--watch-path=template.html']]);
132+
await assertExecArgv(
133+
['--watch-path', 'template.html', file],
134+
[
135+
['--watch-path', 'template.html'],
136+
['--watch-path=template.html'],
137+
]);
123138
});
124139
});

0 commit comments

Comments
 (0)