Skip to content

Commit a50df99

Browse files
test(sandbox): use lastIndexOf to clean up watch flags
Address review feedback on #4104: when the test runner itself is started with `node --watch`, the existing indexOf() cleanup would strip the runner's flag. Since each watchFlag is appended via push(), lastIndexOf() reliably targets our own entry without disturbing pre-existing values.
1 parent c7b698a commit a50df99

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

tests/child-pool.test.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,12 @@ function sandboxProcessTests(
142142
}
143143
} finally {
144144
// Remove only the flags we added so we don't disturb sibling tests
145-
// that also mutate process.execArgv.
145+
// that also mutate process.execArgv. We push() each flag onto the
146+
// end, so lastIndexOf() targets our own entry — using indexOf()
147+
// would remove a pre-existing --watch* if the runner itself was
148+
// started with `node --watch`.
146149
for (const flag of watchFlags) {
147-
const idx = process.execArgv.indexOf(flag);
150+
const idx = process.execArgv.lastIndexOf(flag);
148151
if (idx !== -1) {
149152
process.execArgv.splice(idx, 1);
150153
}

0 commit comments

Comments
 (0)