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
- Loading branch information
Showing
19 changed files
with
324 additions
and
854 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,164 @@ | ||
'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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.