mirror of
https://github.com/facebook/react.git
synced 2026-02-22 03:42:05 +00:00
Jest's default test sequencer sorts alphabetically, causing large test files (eg ReactDOMFloat-test.js at 9k lines, ReactHooksWithNoopRenderer-test.js at 4k lines) to cluster in shard 3/5. This made shard 3/5 average 117s vs 77s for other shards, a 52% slowdown. I'm using filesize as a rough proxy for number of tests. This custom sequencer sorts tests by file size and distributes large files evenly across all shards instead of clustering them together. --- [//]: # (BEGIN SAPLING FOOTER) Stack created with [Sapling](https://sapling-scm.com). Best reviewed with [ReviewStack](https://reviewstack.dev/facebook/react/pull/35458). * __->__ #35458 * #35459
43 lines
1.4 KiB
JavaScript
43 lines
1.4 KiB
JavaScript
'use strict';
|
|
|
|
module.exports = {
|
|
globalSetup: require.resolve('./setupGlobal.js'),
|
|
testSequencer: require.resolve('./sizeBalancedSequencer.js'),
|
|
modulePathIgnorePatterns: [
|
|
'<rootDir>/scripts/rollup/shims/',
|
|
'<rootDir>/scripts/bench/',
|
|
'<rootDir>/packages/eslint-plugin-react-hooks/',
|
|
],
|
|
transform: {
|
|
'^.+babel-plugin-react-compiler/dist/index.js$': [
|
|
'babel-jest',
|
|
{
|
|
configFile: require.resolve('../../babel.config-react-compiler.js'),
|
|
},
|
|
],
|
|
'^.+\\.ts$': [
|
|
'babel-jest',
|
|
{configFile: require.resolve('../../babel.config-ts.js')},
|
|
],
|
|
'.(?!ts$)': require.resolve('./preprocessor.js'),
|
|
},
|
|
prettierPath: require.resolve('prettier-2'),
|
|
setupFiles: [require.resolve('./setupEnvironment.js')],
|
|
setupFilesAfterEnv: [require.resolve('./setupTests.js')],
|
|
// Only include files directly in __tests__, not in nested folders.
|
|
testRegex: '/__tests__/[^/]*(\\.js|\\.coffee|[^d]\\.ts)$',
|
|
moduleFileExtensions: ['js', 'json', 'node', 'coffee', 'ts'],
|
|
rootDir: process.cwd(),
|
|
roots: ['<rootDir>/packages', '<rootDir>/scripts'],
|
|
collectCoverageFrom: ['packages/**/*.js'],
|
|
fakeTimers: {
|
|
enableGlobally: true,
|
|
legacyFakeTimers: true,
|
|
},
|
|
snapshotSerializers: [require.resolve('jest-snapshot-serializer-raw')],
|
|
|
|
testEnvironment: '<rootDir>/scripts/jest/ReactJSDOMEnvironment',
|
|
|
|
testRunner: 'jest-circus/runner',
|
|
};
|