Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
const testFileExtension = 'ts?(x)';

// Reassure runs only the performance tests, matched by the `.perf-test` suffix / `__perf__` folder,
// which it passes to Jest as `--testMatch`. We detect that from the test-runner argv so we can leave
// `performance` real for perf runs only: enabling Jest's modern fake timers globally also fakes
// `performance`, and React's Scheduler captures that (frozen) clock once at module load, which zeroes
// every React Profiler render duration — and thus every Reassure `[render]` measurement.
const isPerfTestRun = process.argv.some((arg) => arg.includes('perf-test') || arg.includes('__perf__'));

module.exports = {
preset: 'jest-expo',
collectCoverageFrom: ['<rootDir>/src/**/*.{ts,tsx,js,jsx}', '!<rootDir>/src/**/__mocks__/**', '!<rootDir>/src/**/tests/**', '!**/*.d.ts'],
Expand Down Expand Up @@ -29,7 +37,9 @@ module.exports = {
},
fakeTimers: {
enableGlobally: true,
doNotFake: ['nextTick'],
// `nextTick` is never faked because Onyx notifies its subscribers on process.nextTick.
// `performance` is left real only for perf runs (see isPerfTestRun above).
doNotFake: isPerfTestRun ? ['nextTick', 'performance'] : ['nextTick'],

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Keep Reassure baselines on the same clock

In PRs that contain this migration, the Reassure workflow does not run the same Jest config for the two samples: I checked .github/workflows/reassurePerformanceTests.yml, where the baseline job force-checks out origin/$BASELINE_BRANCH before npx reassure --baseline (lines 21-30), while the branch job runs this checkout (lines 50-55). That means this new doNotFake only applies to the current sample; the baseline sample still has the old fake performance clock and records [render] durations as 0, so the comparison is non-zero real durations vs zeroed baselines and the perf result is invalid for the change that restores timing. Please ensure both sides use the same timer behavior during this migration.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

main is a baseline branch so it needs to land to work

},
testEnvironment: 'jsdom',
setupFiles: ['<rootDir>/jest/setup.ts', './node_modules/@react-native-google-signin/google-signin/jest/build/setup.js'],
Expand Down
Loading