You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(ext/node): node:test with watch-mode events (#34254)
## Summary
- Replaces `notImplemented("test.run")` in
`ext/node/polyfills/testing.ts` with a real `TestsStream`-compatible
`Readable`.
- Supports `run({ watch, cwd, signal })`: emits `test:watch:drained`
after each run cycle, and `test:watch:restarted` (followed by `drained`)
when a file changes under the watched cwd.
- The returned stream both pushes events as data chunks (for async
iteration / `'data'` listeners) and emits each event under its `type` as
a named event, matching Node's `TestsStream` semantics so callers can do
`stream.on('test:watch:drained', ...)` directly.
- `AbortSignal` ends the stream and closes the watcher; bursts of fs
events are debounced (~50ms) so a single user-visible change triggers
exactly one restart cycle.
## Scope
This PR implements the watch-mode event machinery only. Programmatic
test discovery / execution under `run()` (which would let it actually
emit `test:pass`/`test:fail`) is deliberately left for a follow-up; the
stream emits empty run cycles for now. That is enough to unblock the
watch-event fixtures in the Node compat suite that drive behavior
through the programmatic API rather than spawning a subprocess.
Five previously-absent test-runner watch fixtures now pass and are added
to \`tests/node_compat/config.jsonc\`:
- \`test-runner/test-run-watch-cwd.mjs\`
- \`test-runner/test-run-watch-cwd-isolation-none.mjs\`
- \`test-runner/test-run-watch-cwd-isolation-process.mjs\`
- \`test-runner/test-run-watch-emit-restarted.mjs\` (validates the
drained/restarted/drained sequence via
\`assert.partialDeepStrictEqual\`)
- \`test-runner/test-run-watch-no-emit-restarted-disabled.mjs\`
(validates that \`watch: false\` never emits \`test:watch:restarted\`
via \`common.mustNotCall\`)
The remaining \`test-run-watch-*\` and \`test-watch-*-isolation-*\`
fixtures depend on subprocess spawning of a \`run()\`-fixture piped
through \`node:test/reporters\` \`tap\`, or on CLI \`--test --watch\`
flags - both substantial separate features and out of scope for this PR.
Co-authored-by: divybot <divybot@users.noreply.github.com>
Co-authored-by: Divy Srivastava <me@littledivy.com>
0 commit comments