Skip to content

feat: don't report scenarios from skipped test files as removed - #596

Open
adhorodyski wants to merge 2 commits into
callstack:mainfrom
adhorodyski:feat/skip-unselected-scenarios-in-compare
Open

adhorodyski wants to merge 2 commits into
callstack:mainfrom
adhorodyski:feat/skip-unselected-scenarios-in-compare

Conversation

@adhorodyski

@adhorodyski adhorodyski commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Summary

When a run measures only some perf test files (e.g. reassure --testMatch '<glob>', or reassure -- --findRelatedTests <files> to measure only the tests a PR touches), reassure-compare reports every baseline scenario missing from the current run as Removed. On a selective run that is almost the whole baseline.

Results written before this change have no testPath and compare exactly as before.

Context

Expensify/App runs this as a patch-package patch on 1.6.1 to measure only the selected perf tests on PRs: Expensify/App#107158.

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@mdjastrzebski mdjastrzebski left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Problems found during manual verification

I ran yarn reassure in test-apps/native at commit 9b1577f.

❌ A test file that runs but records no entries hides its scenarios

compareResults in packages/compare/src/compare.ts builds currentTestPaths only from the entries of the current run. Thus, a test file that ran but wrote no entries looks the same as a file that the run skipped. Its baseline scenarios are not listed in "Removed Entries".

This occurs when:

  • All tests in a file use test.skip.
  • A user deletes all perf scenarios from a file, but keeps the file.

Steps to reproduce:

  1. In test-apps/native, run yarn reassure --baseline.
  2. In src/RedundantRenders.perf.tsx, change each test( to test.skip(.
  3. Run yarn reassure --testMatch '**/@(fib|RedundantRenders).perf.[jt]s?(x)'.

Expected: "Removed Entries" lists InitialRenders 1, InitialRenders 3, RedundantUpdates, and ManyRenderIssues.

Actual: "Removed Entries" does not list these 4 scenarios. Without testPath in the baseline (the behavior before this PR), the same comparison lists all 4.

Possible fixes:

  • Record the test files that ran, not only the entries. For example, reassure-measure can write one marker line for each test file, or the CLI can save the list of test files from Jest next to current.perf.
  • Alternatively, document this limitation in docusaurus/docs/methodology.md.

❌ The example command in the PR description does not work

The description gives reassure --testPathPattern ... as an example. The CLI rejects it with Unknown argument: testPathPattern.

To run a subset of perf test files, use one of these:

  • reassure --testMatch '<glob>'
  • reassure --testRegex '<regex>'
  • The TEST_RUNNER_ARGS environment variable (for example, with --findRelatedTests)

Please correct the example in the description.

@mdjastrzebski

Copy link
Copy Markdown
Member

Review findings (verified)

An automated code review of this PR found 6 issues. A second pass checked each finding against the code at 9b1577f. All 6 are confirmed. Only F5 has a realistic effect on users. The other 5 are low severity.

Terms:

  • Hidden scenario: a baseline scenario that compareResults leaves out because its test file still exists but has no entry in the current results.
  • currentTestPaths: the set of testPath values from the current entries (packages/compare/src/compare.ts:136).
ID Severity Where Finding
F5 medium packages/compare/src/compare.ts:155 Hidden scenarios are never mentioned in output
F1 low packages/compare/src/compare.ts:153 File that ran with zero entries looks skipped
F2 low packages/compare/src/compare.ts:136 No testPath in current run hides scenarios
F3 low packages/measure/src/output.ts:17 testPath depends on the working directory
F4 low packages/compare/src/compare.ts:189 Run stability compares different scenario sets
F6 low packages/measure/src/output.ts:12 No test for the new testPath output

⚠️ F5: hidden scenarios are never reported

  • The skip branch (compare.ts:155-162) drops the entry. CompareResult has no list or count of skipped entries.
  • So the console and markdown output never say that baseline scenarios were left out.
  • Risk: a file that stops running but still exists is dropped on every run with no sign. Examples: a testMatch or testPathIgnorePatterns change, or a rename to an extension that does not match.
  • The omission is intentional and is described in docusaurus/docs/methodology.md. It is a design gap, not a bug.
  • Fix: collect the skipped entries (for example a skipped list on CompareResult). Print their count in the console and markdown output.

F1: a file that ran with zero entries looks skipped

  • currentTestPaths is built only from the current entries. Nothing else records which test files ran.
  • Example: a developer keeps src/List.perf-test.tsx but removes or it.skips all its measure calls. The file exists and has no current entry, so its removed scenarios are hidden. They do not show under "Removed Scenarios".
  • Effect: only the "Removed Scenarios" list is affected, and only in this edge case.
  • Fix: record the test files that ran, separately from the entries. Filter against that list. Options: a per-file marker line from reassure-measure, or the list of executed test files from Jest, passed in by the CLI.

F2: no testPath in the current run hides scenarios

  • testPath is optional (type-schemas.ts:26). JSON.stringify drops it when it is undefined.
  • If no current entry has a testPath, then currentTestPaths is {undefined}. Every baseline scenario whose file exists is then hidden.
  • When it happens: the baseline comes from the new reassure-measure, and the current run comes from an older reassure-measure (for example, a pinned version or a downgrade).
  • ✅ An old baseline with a new current run works, because the baseline entries have no testPath, so the filter does not apply.
  • Fix: apply the skip filter only when the current entries record at least one testPath.

F3: testPath depends on the working directory

  • reassure-measure stores path.relative(process.cwd(), testPath) with no normalization (output.ts:17).
  • compareResults looks up the string in a plain Set, and calls fs.existsSync relative to its own working directory.
  • If the baseline and current runs use different working directories or operating systems (\ and / separators), the strings do not match.
  • Effect: in most cases the scenario goes back to being listed as removed (the old behavior). A removed scenario is hidden only if the old string also resolves from the working directory of compareResults.
  • Fix: store a POSIX path relative to a fixed root (for example the Jest rootDir or the git root). Resolve it against the same root in compareResults.

F4: run stability compares different scenario sets

  • calculateRunStability(baseline) (compare.ts:189) uses the full baseline, including hidden scenarios. Current stability covers only the files that ran.
  • The console and markdown reports show the two values side by side.
  • Example: reassure -- src/Foo.perf-test.tsx against a full baseline compares stability over 50 scenarios with stability over 3.
  • Effect: low. Added and removed scenarios already caused a small mismatch. No verdict depends on this value.
  • Fix: leave hidden scenarios out of baseline stability, or say in the report that the two values cover different sets.

F6: no test for the new measure output

  • The PR adds testPath to the reassure-measure output (output.ts:12-17), but it adds no reassure-measure test.
  • AGENTS.md says: "When behavior changes, update source, tests, and docs together."
  • Fix: add a writeTestStats test that mocks expect.getState(). Check that a relative testPath is written, and that the field is left out when testPath is undefined.

Suggested order

  1. F2: a one-line guard.
  2. F6: a small test.
  3. F5: report the skipped count.
  4. F3: normalize the path.
  5. F1: needs a design decision (how to record which files ran).
  6. F4: optional.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants