Skip to content

✅ Fix React router test state leak#4751

Merged
watson merged 1 commit into
mainfrom
watson/fix-test
Jun 8, 2026
Merged

✅ Fix React router test state leak#4751
watson merged 1 commit into
mainfrom
watson/fix-test

Conversation

@watson

@watson watson commented Jun 8, 2026

Copy link
Copy Markdown
Collaborator

Motivation

While investigating #4750, the BrowserStack Firefox unit job failed with TypeError: rumPublicApi.startView is not a function in reactPlugin.spec.ts.

CI logs: https://gitlab.ddbuild.io/datadog/browser-sdk/-/jobs/1751673091

The failure was order-dependent: wrapCreateRouter regression tests could register pending React router onRumInit subscribers without clearing the React plugin global state, then a later spec initialized the plugin with a minimal fake public API.

Changes

Reset the React plugin before the wrapCreateRouter — initial error forwarding regression tests and register cleanup afterward, so pending subscribers cannot leak into later randomized specs.

This only affects test isolation.

Test instructions

yarn test:unit --spec packages/browser-rum-react/src/domain/reactRouter/createRouter.spec.ts --spec packages/browser-rum-react/src/domain/reactPlugin.spec.ts --seed 11837

Checklist

  • Tested locally
  • Tested on staging
  • Added unit tests for this change.
  • Added e2e/integration tests for this change.
  • Updated documentation and/or relevant AGENTS.md file

Reset the React plugin around wrapCreateRouter regression tests so pending
onRumInit subscribers do not leak into later specs with randomized test order.

The leak caused BrowserStack Firefox unit runs to fail when reactPlugin specs
initialized the plugin with a minimal fake public API.
@watson watson requested a review from a team as a code owner June 8, 2026 13:02

watson commented Jun 8, 2026

Copy link
Copy Markdown
Collaborator Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@cit-pr-commenter-54b7da

Copy link
Copy Markdown

Bundles Sizes Evolution

📦 Bundle Name Base Size Local Size 𝚫 𝚫% Status
Rum 171.86 KiB 171.86 KiB 0 B 0.00%
Rum Profiler 7.88 KiB 7.88 KiB 0 B 0.00%
Rum Recorder 21.21 KiB 21.21 KiB 0 B 0.00%
Logs 54.31 KiB 54.31 KiB 0 B 0.00%
Rum Slim 129.69 KiB 129.69 KiB 0 B 0.00%
Worker 22.96 KiB 22.96 KiB 0 B 0.00%

@datadog-prod-us1-5

Copy link
Copy Markdown

Tests

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

🎯 Code Coverage (details)
Patch Coverage: 100.00%
Overall Coverage: 76.77% (+0.00%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 0aa05ff | Docs | Datadog PR Page | Give us feedback!

@watson watson merged commit 1d7b07d into main Jun 8, 2026
31 checks passed
@watson watson deleted the watson/fix-test branch June 8, 2026 13:16
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 8, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants