Skip to content

test(node-suite): expand node:test parity coverage#6455

Open
TheHypnoo wants to merge 3 commits into
mainfrom
test/expand-node-test-parity
Open

test(node-suite): expand node:test parity coverage#6455
TheHypnoo wants to merge 3 commits into
mainfrom
test/expand-node-test-parity

Conversation

@TheHypnoo

@TheHypnoo TheHypnoo commented Jul 16, 2026

Copy link
Copy Markdown
Member

Summary

  • add 79 granular node:test fixtures, growing the suite from 11 to 90 cases
  • cover imports/registration (10), TestContext and runner APIs (16), hooks (9), mock functions/properties (27), deterministic mock timers (13), and snapshots/reporters (4)
  • canonicalize reporter durations and source locations while preserving nested indentation, including the CodeRabbit review finding
  • document primary-source selection, stable exclusions, and the stopping judgment
  • ratchet the measured node:test floor from 7/11 to 33/90 and record the clean full-suite result of 2772/2949

Upstream evidence

Selection was compared against current primary repository snapshots:

  • Node.js 34c28d5a69f4f00cd599adcbe57834435d3a683b: test-runner registration, context, hooks, mocking, mock timers, reporters, plans, and snapshots
  • Deno f8a17c8171569fa2870d740030aaa59c91fdf9ee: ext/node/polyfills/testing.ts
  • Bun 6173d6431ee8ad086bf79d1d5354080cfe937964: test/js/node/test_runner compatibility selection and fixtures

Stable diagnostics

The focused result is stable at 33/90. The 57 remaining diffs diagnose:

  • eager top-level registration, flattened suites/subtests, and incomplete parent-child completion
  • incomplete TestContext assertion surface, plan/directive propagation, only selection, metadata, and failure propagation
  • hooks running at registration rather than around tests, including incomplete throw cleanup
  • missing accessor/property mock behavior, call metadata, validation, once-index, tracker reset, and constructable wrapper semantics
  • incomplete deterministic timer validation, interval/reset behavior, snapshot validation, and nested reporter/directive semantics

Passing coverage now includes async and callback registration, assertion/context surfaces, multiple hook ordering, inherited/symbol/accessor/property mocks, call records and restoration, deterministic Date/timeout/interval behavior, snapshot validation, and canonicalized nested reporter output.

Verification

  • cargo build --profile perry-dev -p perry -p perry-runtime-static -p perry-stdlib-static — passed for the initial branch revision; the follow-up changes only fixtures, documentation, baseline data, and the Python harness
  • NODE_BIN="$HOME/.nvm/versions/node/v26.5.0/bin/node" PERRY_RUNTIME_DIR="/Users/sergigonzalez/.codex/worktrees/8d98/perry/target/perry-dev" python3 scripts/node_suite_run.py "/Users/sergigonzalez/.codex/worktrees/8d98/perry/target/perry-dev/perry" "$PWD" test — repeated clean result: 33/90, 57 diagnostic diffs
  • same command without the test module filter — clean full result: 2772/2949 (94.0%)
  • git diff --cached --check / git diff --check — passed
  • cargo fmt --all -- --check — passed
  • Python AST and JSON parse checks — passed
  • nested reporter-normalization regression check — passed
  • ./scripts/check_file_size.sh — passed

The full run retained unrelated existing/environment-sensitive deficits; their module floors were not lowered.

Exclusions

CLI discovery, watch mode, coverage, source maps, isolation, global setup, worker IDs, concurrency, randomization, abort/timeout scheduling, refed handles, TTY/color formatting, module mocking, and snapshot update/CLI behavior remain separate runtime or CLI work. Unclaimed TestContext APIs (waitFor, runOnly, tags, full names, signals, and custom assertions) are not counted as Perry coverage. Constructor-target mocks remain deferred because Perry's wrappers are not constructable. Re-enabling an already enabled mock-timer context remains excluded because Perry leaves a live handle after the validation error.

Summary by CodeRabbit

  • New Features

    • Expanded deterministic parity coverage for the Node.js test runner, including nested suites, hooks, plans, skips/todos, mocks, mock timers, and reporter output behavior.
  • Bug Fixes

    • Improved comparison stability by better normalizing test durations and source-location details (including timer-style and summary duration lines).
  • Documentation

    • Added documentation describing the deterministic parity methodology and clearly listing supported vs intentionally excluded scenarios.
  • Tests

    • Updated parity baseline results to reflect the improved normalization and expanded coverage.

@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Changes

Node test parity

Layer / File(s) Summary
Parity normalization and baseline
scripts/node_suite_run.py, test-parity/node-suite/test/README.md, test-parity/node_suite_baseline.json
Normalizes test durations and locations, documents parity coverage and exclusions, and updates Node baseline metadata and floor counts.
Runner registration and context coverage
test-parity/node-suite/test/imports/*, test-parity/node-suite/test/runner/api/*, test-parity/node-suite/test/runner/registration/*, test-parity/node-suite/test/runner/context/*, test-parity/node-suite/test/snapshots/*, test-parity/node-suite/test/reporters/*
Adds scenarios covering imports, runner execution, nested registration, context metadata, assertions, directives, plans, snapshots, reporters, and failure propagation.
Runner hook lifecycle coverage
test-parity/node-suite/test/runner/hooks/*
Adds scenarios for hook ordering, nested hooks, cleanup, setup failures, body failures, context names, and runtime skips.
Mock function API coverage
test-parity/node-suite/test/mock-fn/*
Adds coverage for mock implementations, accessors, properties, call records, restoration, reset behavior, prototypes, symbols, limited calls, and validation errors.
Mock timer coverage
test-parity/node-suite/test/mock-timers/*
Adds coverage for mocked dates, timeouts, intervals, cancellation, nested timer flushing, tick boundaries, callback arguments, reset behavior, and validation errors.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title is concise and accurately summarizes the main change: expanded node:test parity coverage.
Description check ✅ Passed The description is detailed and covers summary, evidence, verification, and exclusions, though it omits explicit Changes and Related issue sections.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test/expand-node-test-parity

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@scripts/node_suite_run.py`:
- Around line 51-66: Update normalize and the _TEST_LOCATION pattern to accept
optional leading whitespace before test-location lines and “ℹ duration_ms”
diagnostics, while preserving the existing canonical replacements and
indentation handling for nested suites.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 1732e523-90bf-49d9-9fa3-c4dc3e7fa39a

📥 Commits

Reviewing files that changed from the base of the PR and between ebd1fe8 and 7e0ac7e.

📒 Files selected for processing (35)
  • scripts/node_suite_run.py
  • test-parity/node-suite/test/README.md
  • test-parity/node-suite/test/mock-fn/accessor-options.ts
  • test-parity/node-suite/test/mock-fn/call-record-errors.ts
  • test-parity/node-suite/test/mock-fn/implementations.ts
  • test-parity/node-suite/test/mock-fn/method-restore-chain.ts
  • test-parity/node-suite/test/mock-fn/property-context.ts
  • test-parity/node-suite/test/mock-fn/times-options.ts
  • test-parity/node-suite/test/mock-fn/tracker-reset-restore.ts
  • test-parity/node-suite/test/mock-fn/validation.ts
  • test-parity/node-suite/test/mock-timers/date-set-time.ts
  • test-parity/node-suite/test/mock-timers/run-all-nested.ts
  • test-parity/node-suite/test/mock-timers/tick-boundary-order.ts
  • test-parity/node-suite/test/runner/api/run-empty.ts
  • test-parity/node-suite/test/runner/context/assertions.ts
  • test-parity/node-suite/test/runner/context/failure-propagation.ts
  • test-parity/node-suite/test/runner/context/metadata-values.ts
  • test-parity/node-suite/test/runner/context/only-registration.ts
  • test-parity/node-suite/test/runner/context/plan-match.ts
  • test-parity/node-suite/test/runner/context/plan-mismatch.ts
  • test-parity/node-suite/test/runner/context/plan-overrun.ts
  • test-parity/node-suite/test/runner/context/plan-zero.ts
  • test-parity/node-suite/test/runner/context/runtime-directives.ts
  • test-parity/node-suite/test/runner/hooks/after-each-after-throw.ts
  • test-parity/node-suite/test/runner/hooks/before-throw-cleanup.ts
  • test-parity/node-suite/test/runner/hooks/cleanup-after-throw.ts
  • test-parity/node-suite/test/runner/hooks/nested-before-each-throw.ts
  • test-parity/node-suite/test/runner/hooks/nested-suites.ts
  • test-parity/node-suite/test/runner/hooks/runtime-skip-after-each.ts
  • test-parity/node-suite/test/runner/hooks/top-level-order.ts
  • test-parity/node-suite/test/runner/registration/nested-subtests.ts
  • test-parity/node-suite/test/runner/registration/parent-child-completion.ts
  • test-parity/node-suite/test/runner/registration/suite-nesting.ts
  • test-parity/node-suite/test/runner/registration/top-level-order.ts
  • test-parity/node_suite_baseline.json

Comment thread scripts/node_suite_run.py Outdated
@proggeramlug proggeramlug added the ready PR triaged: CodeRabbit feedback + conflicts addressed label Jul 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready PR triaged: CodeRabbit feedback + conflicts addressed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants