feat(tracing): Add Sentry.NavigationContainer wrapper for React Navigation #6199
3 issues
Low
Module-level `_warned*` flags not reset between test cases cause flaky warning assertions
In NavigationContainer.tsx, _warnedNoClient and _warnedNoIntegration are module-level singletons. jest.clearAllMocks() in beforeEach resets mock call counts but not these flags, so if a test that triggers a warning runs before another test asserting on the same warning mock, the second assertion will fail. Consider resetting these flags via a test-only export or using jest.resetModules().
Module-level `_warned*` flags persist across tests, making warning assertions order-dependent - `packages/core/src/js/index.ts:117`
NavigationContainer.tsx declares three module-level booleans (_warnedMissing, _warnedNoClient, _warnedNoIntegration) that are set to true on first trigger and never reset. The test suite's beforeEach calls only jest.clearAllMocks(), which does not reset module state. Currently each warning branch is asserted in exactly one test, so the suite passes; however, if either of the two warning tests is duplicated, reordered, or a new test exercises the same branch, debug.warn/debug.log will not fire again and the assertion will silently fail. Consider adding jest.resetModules() (with dynamic re-import) or jest.isolateModules around the warning tests, or exposing a test-only reset helper to keep these assertions robust.
Also found at:
packages/core/test/NavigationContainer.test.tsx:56
Module-level warning flags are never reset, causing silent test failures and missed re-warnings - `packages/core/src/js/NavigationContainer.tsx:6-9`
The three module-level booleans (_warnedMissing, _warnedNoClient, _warnedNoIntegration) are set once per process lifetime; jest.clearAllMocks() in beforeEach does not reset them, so any new test that exercises the same warning path will silently skip the debug.warn/debug.log assertion.
4 skills analyzed
| Skill | Findings | Duration | Cost |
|---|---|---|---|
| security-review | 0 | 7.2s | $0.05 |
| code-review | 2 | 3m 38s | $1.18 |
| find-bugs | 1 | 10m 28s | $2.16 |
| gha-security-review | 0 | 2m 1s | $0.02 |
โฑ 16m 14s ยท 1.2M in / 117.0k out ยท $3.41