Skip to content

fix: dedupe generated browser tests to avoid doubled in-flight counters#594

Open
yann-copilot wants to merge 1 commit into
storybookjs:nextfrom
yann-copilot:fix/dedupe-browser-tests-counter
Open

fix: dedupe generated browser tests to avoid doubled in-flight counters#594
yann-copilot wants to merge 1 commit into
storybookjs:nextfrom
yann-copilot:fix/dedupe-browser-tests-counter

Conversation

@yann-copilot

Copy link
Copy Markdown

Fixes #276

Summary

When browser tests are expanded in PlaywrightRunner#getTests, duplicate generated entries can inflate in-flight test counters in Jest output (e.g. showing ~2x tests while running, then settling at the expected total at the end).

This patch dedupes generated browser tests before execution using a stable key:

  • test path
  • browser name
  • device name
  • display name

Why this helps

The in-flight counter is based on the expanded test list. If that list contains duplicates, users see misleading progress totals.

By deduping before super.runTests(...), progress reporting remains stable and matches final totals.

Changes

  • src/jest-playwright-preset/PlaywrightRunner.ts

    • add dedupeBrowserTests helper
    • apply it to the generated pwTests list
  • src/jest-playwright-preset/PlaywrightRunner.test.ts

    • verifies duplicates are removed
    • verifies distinct browser entries are preserved

Validation

corepack yarn test src/jest-playwright-preset/PlaywrightRunner.test.ts

@codecov

codecov Bot commented Mar 2, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 91.30435% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 24.80%. Comparing base (6bff30e) to head (d16d5a9).
⚠️ Report is 141 commits behind head on next.

Files with missing lines Patch % Lines
src/jest-playwright-preset/PlaywrightRunner.ts 91.30% 2 Missing ⚠️

❗ There is a different number of reports uploaded between BASE (6bff30e) and HEAD (d16d5a9). Click for more details.

HEAD has 1 upload less than BASE
Flag BASE (6bff30e) HEAD (d16d5a9)
2 1
Additional details and impacted files
@@             Coverage Diff             @@
##             next     #594       +/-   ##
===========================================
- Coverage   93.19%   24.80%   -68.40%     
===========================================
  Files          15       41       +26     
  Lines         294     2818     +2524     
  Branches       78      159       +81     
===========================================
+ Hits          274      699      +425     
- Misses         20     2100     +2080     
- Partials        0       19       +19     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

[Bug] Test-runner shows double the amount of tests before it finishes running

1 participant