Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use jest projects instead of custom jest wrapper
This uses Jest's first party support for "projects" instead of passing different config flags to jest. This should make it easier to locally run all variations of a single test and removes all the custom argument parsing. ## TODO - is the outcome actually easier? - look into devtools tests - `ReactClassEquivalence-test` is disabled for now - figure out how to handle the "build" variants, I'm thinking those might be a different package.json script that sets an env variable as it's probably rarely used locally (super slow to build before)
- Loading branch information
Showing
20 changed files
with
375 additions
and
856 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,171 @@ | ||
/** | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
'use strict'; | ||
|
||
function createConfig({releaseChannel, env, variant, persistent}) { | ||
let displayName = `${releaseChannel}-${env}`; | ||
if (variant === true) { | ||
displayName += '-variant'; | ||
} | ||
if (persistent) { | ||
displayName += '-persistent'; | ||
} | ||
|
||
const setupFiles = []; | ||
if (variant) { | ||
setupFiles.push(require.resolve('./scripts/jest/setupEnvVariant.js')); | ||
} | ||
switch (env) { | ||
case 'development': | ||
setupFiles.push(require.resolve('./scripts/jest/setupEnvDevelopment.js')); | ||
break; | ||
case 'production': | ||
setupFiles.push(require.resolve('./scripts/jest/setupEnvProduction.js')); | ||
break; | ||
default: | ||
throw new Error(`Unexpected env: ${env}`); | ||
} | ||
setupFiles.push(require.resolve('./scripts/jest/setupEnvironment.js')); | ||
if (persistent) { | ||
setupFiles.push(require.resolve('./scripts/jest/setupTests.persistent.js')); | ||
} else { | ||
switch (releaseChannel) { | ||
case 'www-classic': | ||
case 'www-modern': | ||
setupFiles.push(require.resolve('./scripts/jest/setupTests.www.js')); | ||
break; | ||
case 'experimental': | ||
case 'stable': | ||
// no special setup files | ||
break; | ||
default: | ||
throw new Error(`Unexpected release channel: ${releaseChannel}`); | ||
} | ||
} | ||
setupFiles.push(require.resolve('./scripts/jest/setupHostConfigs.js')); | ||
|
||
const modulePathIgnorePatterns = [ | ||
'<rootDir>/scripts/rollup/shims/', | ||
'<rootDir>/scripts/bench/', | ||
'packages/react-devtools-extensions', | ||
'packages/react-devtools-shared', | ||
]; | ||
|
||
if (persistent) { | ||
modulePathIgnorePatterns.push( | ||
'ReactIncrementalPerf', | ||
'ReactIncrementalUpdatesMinimalism', | ||
'ReactIncrementalTriangle', | ||
'ReactIncrementalReflection', | ||
'forwardRef' | ||
); | ||
} | ||
|
||
return { | ||
displayName, | ||
setupFiles, | ||
modulePathIgnorePatterns, | ||
transform: { | ||
'.*': | ||
env === 'development' | ||
? require.resolve('./scripts/jest/preprocessor.dev.js') | ||
: require.resolve('./scripts/jest/preprocessor.prod.js'), | ||
}, | ||
prettierPath: require.resolve('prettier-2'), | ||
setupFilesAfterEnv: [require.resolve('./scripts/jest/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'], | ||
fakeTimers: { | ||
enableGlobally: true, | ||
legacyFakeTimers: true, | ||
}, | ||
snapshotSerializers: [require.resolve('jest-snapshot-serializer-raw')], | ||
testEnvironment: 'jsdom', | ||
testRunner: 'jest-circus/runner', | ||
}; | ||
} | ||
|
||
module.exports = { | ||
globalSetup: require.resolve('./scripts/jest/setupGlobal.js'), | ||
collectCoverageFrom: ['packages/**/*.js'], | ||
|
||
projects: [ | ||
createConfig({ | ||
releaseChannel: 'stable', | ||
env: 'development', | ||
}), | ||
createConfig({ | ||
releaseChannel: 'stable', | ||
env: 'production', | ||
}), | ||
createConfig({ | ||
releaseChannel: 'stable', | ||
env: 'development', | ||
persistent: true, | ||
}), | ||
|
||
createConfig({ | ||
releaseChannel: 'experimental', | ||
env: 'development', | ||
}), | ||
createConfig({ | ||
releaseChannel: 'experimental', | ||
env: 'production', | ||
}), | ||
createConfig({ | ||
releaseChannel: 'experimental', | ||
env: 'development', | ||
persistent: true, | ||
}), | ||
|
||
createConfig({ | ||
releaseChannel: 'www-classic', | ||
env: 'development', | ||
variant: false, | ||
}), | ||
createConfig({ | ||
releaseChannel: 'www-classic', | ||
env: 'production', | ||
variant: false, | ||
}), | ||
createConfig({ | ||
releaseChannel: 'www-classic', | ||
env: 'development', | ||
variant: true, | ||
}), | ||
createConfig({ | ||
releaseChannel: 'www-classic', | ||
env: 'production', | ||
variant: true, | ||
}), | ||
|
||
createConfig({ | ||
releaseChannel: 'www-modern', | ||
env: 'development', | ||
variant: false, | ||
}), | ||
createConfig({ | ||
releaseChannel: 'www-modern', | ||
env: 'production', | ||
variant: false, | ||
}), | ||
createConfig({ | ||
releaseChannel: 'www-modern', | ||
env: 'development', | ||
variant: true, | ||
}), | ||
createConfig({ | ||
releaseChannel: 'www-modern', | ||
env: 'production', | ||
variant: true, | ||
}), | ||
], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.