feat(collect-tests): expand .each and report accurate per-status counts - #16259
Open
alexander-turner wants to merge 11 commits into
Open
feat(collect-tests): expand .each and report accurate per-status counts#16259alexander-turner wants to merge 11 commits into
alexander-turner wants to merge 11 commits into
Conversation
…s counts
`--collectTests` now categorizes each collected test exactly as a real run
would: runnable tests as `passed`, `test.skip` / focus-deselected tests as
`pending`, and `test.todo` as `todo`. `test.each`/`describe.each` cases were
already expanded at file-load time; this makes the reported counts
(numPassedTests/numPendingTests/numTodoTests/numTotalTests) match an actual
run, so the feature can be used to count tests without executing them.
Also adds a summary line ("Test suites:" / "Tests:") to the non-JSON output
and a shared `makeCollectedTestResult` helper in `@jest/test-result` used by
both the circus and jasmine2 collection paths.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SxLxB6jEJZjteeSJyphqJZ
Addresses two issues found in self-review: - `--testNamePattern` no longer drops deselected tests from the collected counts. A real run reports pattern-deselected tests as pending, so they are now collected as `pending` too — making `numTotalTests` match a real run even when a pattern is supplied (previously the totals diverged). - Selected-but-unexecuted tests are reported in the `passed` bucket (so the counts add up) but are now additionally flagged with a new `AssertionResult.wouldRun` field, so JSON consumers can distinguish "would run" from "actually passed" rather than the status silently implying the test ran. Adds e2e parity coverage under `--testNamePattern` and unit coverage for the new pending/wouldRun behaviour. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SxLxB6jEJZjteeSJyphqJZ
…rors Two issues found in self-review of the human (non-JSON) collect output: - The tree printed every collected test name with no status, so under `--testNamePattern` (or with skipped/todo tests) runnable and non-runnable tests looked identical. Skipped and todo entries are now annotated (`[skipped]`/`[todo]`); runnable tests stay bare. - A test file that threw while loading was silently omitted: the tree showed only the healthy files and the summary gave no hint, despite a non-zero exit code. Such files are now printed with their error, and the summary reports how many suites failed to load. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SxLxB6jEJZjteeSJyphqJZ
Tighten the change without losing coverage: - `makeCollectedTestResult` tallies via a small `count` helper instead of a switch. - Consolidate e2e cases (parametrize the real-run parity test over unfiltered/`--testNamePattern`, fold redundant tree/JSON checks) and slim the circus/jasmine unit suites and the kitchenSink/focused fixtures. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SxLxB6jEJZjteeSJyphqJZ
`--collectTests` on the jasmine2 runner ignored `fit`/`fdescribe` focus, so focus-deselected specs were reported as runnable instead of pending, making collected counts diverge from a real run. Mirror jasmine's selection by exposing the env's focused-runnable ids and applying the same enabled/disabled precedence as `Spec.status` (focus-out and explicitly disabled specs collect as pending). Also honor the `disabled` flag and restore sibling-order coverage. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GAFTg2RjfGahzhujmr55k3
`spec.disable()` has a single caller, gated on the same `testNamePattern` the collection already re-derives via `testNamePatternRE`, so the separate `disabled` branch could never select a spec the pattern path didn't. Remove the field, branch, and its test; keep focus handling. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GAFTg2RjfGahzhujmr55k3
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SxLxB6jEJZjteeSJyphqJZ
Move the non-JSON collect rendering (per-file tree, failed-to-load reporting, summary line) into an exported `printCollectedResults`, and unit-test it so the output paths are covered without relying on e2e subprocesses. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SxLxB6jEJZjteeSJyphqJZ
Cover the per-status tally directly (it was only exercised through the built package via the runners), so the collect-tests counting logic is measured. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SxLxB6jEJZjteeSJyphqJZ
The summary line bolds only the total count (`chalk.bold(numTotalTests)`),
so with colors enabled the output is `\x1b[1m3\x1b[22m total` and the
literal `toContain('3 total')` assertion fails. This surfaced as a
Windows-only CI failure where chalk detects color support. Strip ANSI
escapes before the summary assertions so the test is color-agnostic.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FYsdWss8a6bhnzXTS5uWgX
✅ Deploy Preview for jestjs ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
babel-jest
babel-plugin-jest-hoist
babel-preset-jest
create-jest
@jest/diff-sequences
expect
@jest/expect-utils
jest
jest-changed-files
jest-circus
jest-cli
jest-config
@jest/console
@jest/core
@jest/create-cache-key-function
jest-diff
jest-docblock
jest-each
@jest/environment
jest-environment-jsdom
@jest/environment-jsdom-abstract
jest-environment-node
@jest/expect
@jest/fake-timers
@jest/get-type
@jest/globals
jest-haste-map
jest-jasmine2
jest-leak-detector
jest-matcher-utils
jest-message-util
jest-mock
@jest/pattern
jest-phabricator
jest-regex-util
@jest/reporters
jest-resolve
jest-resolve-dependencies
jest-runner
jest-runtime
@jest/schemas
jest-snapshot
@jest/snapshot-utils
@jest/source-map
@jest/test-result
@jest/test-sequencer
@jest/transform
@jest/types
jest-util
jest-validate
jest-watcher
jest-worker
pretty-format
commit: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#16006 added
--collectTeststo report test counts without actually running (potentially heavy) tests. I enhanced the logic to report correctly in more situations:test.each/describe.eachexpand to one entry per casedescribe.skip/ focus-deselected /--testNamePattern-deselected →pending;test.todo→todo; runnable →passed+ newwouldRunflagThe tree also now annotates entries with
[skipped]/[todo]and finishes with a summary line.A suite with
it.each([...10 cases...]), sometest.skipandtest.todo:Before —
.eachcounted as 1, everything lumped as pending, no summary:After — cases expanded, statuses resolved, summary line: