Skip to content

test(js): cover Vitest and Jest dispatch and spawning - #4456

Open
yeahjack wants to merge 15 commits into
rtk-ai:developfrom
yeahjack:test/vitest-jest-command-routing
Open

yeahjack wants to merge 15 commits into
rtk-ai:developfrom
yeahjack:test/vitest-jest-command-routing

Conversation

@yeahjack

@yeahjack yeahjack commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Add end-to-end coverage of rtk vitest and rtk jest, from run_cli dispatch through actual process spawning and output handling
  • Verify executable identity, exact argv (including spaced arguments), direct-tool precedence, and pnpm/yarn/npx lockfile fallback with no package fetching
  • Pin explicit Vitest reporter passthrough for both flag spellings and explicit JSON, failure exit propagation, and reporter stderr diagnostics

Closes #4432. This is the missing wiring coverage after #2418. No production code is changed, so this does not refactor the runner or take over the behavior fixes in #4264 / #3777 / #3680.

Test design

A small native Rust fake is compiled once per test process with the existing Rust toolchain, then installed under each framework/package-manager name. It records its own executable name and argv, so assertions cover the spawned command rather than only an invocation helper. Each child gets a fixture-only PATH; no Node installation, JS project dependencies, shell scripts, or network are needed. The test and fake are portable to Windows, macOS, and Linux. They exercise native executables, not Windows .cmd shim quoting.

Spec-driven re-review

Acceptance was derived from the three observable wiring failures in #4432 and the repository's machine-independent CLI-test rules before inspecting this test suite.

  • J1: Exercise the public CLI through the real spawn. cli_dispatches_each_framework_to_its_own_executable_and_arguments checks both programs, exact argv and direct-tool precedence. Added native_spawn_preserves_argument_boundaries_and_metacharacters covers the forwarded separator, dash-prefixed positional, quotes, backslash and shell metacharacters as literal arguments.
  • J2: Pin reporter passthrough and failures. explicit_vitest_reporter_reaches_the_spawn_and_bypasses_parsing, explicit_reporter_keeps_stderr_diagnostics_and_failure_status, framework_failures_keep_the_child_exit_status, and added reporter_passthrough_also_reaches_the_package_manager cover direct and pnpm-mediated paths, both reporter spellings and explicit JSON.
  • J3: Keep package-manager selection deterministic and offline. missing_framework_uses_the_projects_package_manager_without_fetching checks pnpm/yarn/npx and Bun's no-fetch fallback. Fixtures use temporary cwd, redirected RTK data, fixture-only PATH and native Rust executables.
  • J4: Kill all three issue mutants: swapped dispatch, forced Vitest spawn, and ignored passthrough. Existing invocation unit tests alone survive these mutations; this built-CLI suite must fail each one.

No production code changes. These tests cover native executables on Windows/macOS/Linux, not real Node packages or Windows .cmd shim quoting. Current output semantics intentionally include the existing emitter's trailing newline and reporter stderr in the combined output; changing those belongs to a separate behavior fix.

Verification

  • cargo fmt --all --check, cargo clippy --offline --all-targets, and cargo test --offline --all passed: 4,120 tests passed; 8 pre-existing ignored tests were not run
  • The 7 focused built-CLI regression tests passed
  • rustfmt --check --edition 2024 tests/fixtures/fake_test_runner.rs passed
  • Fresh mutation pass: all 15 existing invocation unit tests survive each of the three mutations; the CLI suite fails for each. All mutations were reverted before the final gate

CI run 37336917035 passed for 9f18e6c393b0e6de9c633e46192285f7f1e75aeb, including Windows/macOS/Linux tests, formatting, clippy, benchmark and security jobs. CLA status passed. The target-branch job is intentionally skipped for the develop base. The optional AI documentation review was skipped because its repository API key is not configured; the job reports success.

The spec-driven self-review has no remaining known in-scope finding. Ready for maintainer review.

@rtk-wshm-sync-bot

Copy link
Copy Markdown

wshm · Automated triage by AI

📊 Automated PR Analysis

🐛 Type bug-fix
🟢 Risk low

Summary

This PR adds end-to-end test coverage for the rtk vitest and rtk jest commands, verifying CLI dispatch, exact argv construction, direct-tool vs package-manager-fallback precedence, reporter passthrough, and exit code/stderr propagation. It introduces a compiled native Rust fake test runner fixture so tests can exercise real process spawning without requiring Node, npm packages, or network access. No production code is modified.

Review Checklist

  • Tests present
  • Breaking change
  • Docs updated

Linked issues: #4432


Analyzed automatically by wshm · This is an automated analysis, not a human review.

@yeahjack
yeahjack marked this pull request as ready for review October 5, 2026 16:04
@yeahjack

Copy link
Copy Markdown
Contributor Author

@aeppling Could you review #4454, #4455 and this PR when you have a chance? They cover Cargo listing passthrough, Go non-JSON preservation, and Vitest/Jest spawning tests. All three are synced with develop and their latest CI is green. Thanks!

@yeahjack
yeahjack force-pushed the test/vitest-jest-command-routing branch from 1e2bdbd to 077effb Compare October 19, 2026 10:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

rtk vitest / rtk jest: the dispatch arm and the spawn wiring have no test

1 participant