mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
chore: upgrade to jest 24 (#15778)
* chore: upgrade to jest 24 * download react-is from npm manually
This commit is contained in:
1 parent
5943b1da6c
commit
e09097a75d
13 files changed
+776
-676
No files matched your search
+4
-3
@@ -62,14 +62,15 @@
|
||||
"google-closure-compiler": "20190301.0.0",
|
||||
"gzip-size": "^3.0.0",
|
||||
"jasmine-check": "^1.0.0-rc.0",
|
||||
"jest": "^23",
|
||||
"jest-diff": "^23",
|
||||
"jest": "^24.9.0",
|
||||
"jest-diff": "^24.9.0",
|
||||
"jest-snapshot-serializer-raw": "^1.1.0",
|
||||
"minimatch": "^3.0.4",
|
||||
"minimist": "^1.2.0",
|
||||
"mkdirp": "^0.5.1",
|
||||
"ncp": "^2.0.0",
|
||||
"object-assign": "^4.1.1",
|
||||
"pacote": "^9.5.6",
|
||||
"prettier": "1.13.7",
|
||||
"prop-types": "^15.6.2",
|
||||
"random-seed": "^0.3.0",
|
||||
@@ -100,7 +101,7 @@
|
||||
"lint": "node ./scripts/tasks/eslint.js",
|
||||
"lint-build": "node ./scripts/rollup/validate/index.js",
|
||||
"extract-errors": "yarn build --type=dev --extract-errors",
|
||||
"postinstall": "node node_modules/fbjs-scripts/node/check-dev-engines.js package.json && node ./scripts/flow/createFlowConfigs.js",
|
||||
"postinstall": "node node_modules/fbjs-scripts/node/check-dev-engines.js package.json && node ./scripts/flow/createFlowConfigs.js && node ./scripts/yarn/downloadReactIsForPrettyFormat.js",
|
||||
"debug-test": "cross-env NODE_ENV=development node --inspect-brk node_modules/.bin/jest --config ./scripts/jest/config.source.js --runInBand",
|
||||
"test": "cross-env NODE_ENV=development jest --config ./scripts/jest/config.source.js",
|
||||
"test-persistent": "cross-env NODE_ENV=development jest --config ./scripts/jest/config.source-persistent.js",
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
},
|
||||
"homepage": "https://reactjs.org/",
|
||||
"peerDependencies": {
|
||||
"jest": "^23.0.1",
|
||||
"jest": "^23.0.1 || ^24.0.0",
|
||||
"scheduler": "^0.15.0"
|
||||
},
|
||||
"files": [
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
},
|
||||
"homepage": "https://reactjs.org/",
|
||||
"peerDependencies": {
|
||||
"jest": "^23.0.1",
|
||||
"jest": "^23.0.1 || ^24.0.0",
|
||||
"react": "^16.0.0",
|
||||
"react-test-renderer": "^16.0.0"
|
||||
},
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
"archiver": "^3.0.0",
|
||||
"babel-core": "^7.0.0-bridge",
|
||||
"babel-eslint": "^9.0.0",
|
||||
"babel-jest": "^24.7.1",
|
||||
"babel-loader": "^8.0.4",
|
||||
"chrome-launch": "^1.1.4",
|
||||
"child-process-promise": "^2.2.1",
|
||||
|
||||
@@ -33,7 +33,6 @@
|
||||
"@babel/preset-react": "^7.0.0",
|
||||
"babel-core": "^7.0.0-bridge",
|
||||
"babel-eslint": "^9.0.0",
|
||||
"babel-jest": "^24.7.1",
|
||||
"babel-loader": "^8.0.4",
|
||||
"cross-env": "^3.1.4",
|
||||
"css-loader": "^1.0.1",
|
||||
|
||||
+2
-3
@@ -25,7 +25,7 @@ export function act(callback: Function): void {
|
||||
});
|
||||
|
||||
// Flush Bridge operations
|
||||
while (global.mockGetTimersCount() > 0) {
|
||||
while (jest.getTimerCount() > 0) {
|
||||
actDOM(() => {
|
||||
actTestRenderer(() => {
|
||||
jest.runAllTimers();
|
||||
@@ -49,8 +49,7 @@ export async function actAsync(
|
||||
});
|
||||
|
||||
if (recursivelyFlush) {
|
||||
// TODO (Jest v24) Replace with jest.getTimerCount() after we upgrade Jest
|
||||
while (global.mockGetTimersCount() > 0) {
|
||||
while (jest.getTimerCount() > 0) {
|
||||
// $FlowFixMe Flow doens't know about "await act()" yet
|
||||
await actDOM(async () => {
|
||||
await actTestRenderer(async () => {
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
"@babel/preset-react": "^7.0.0",
|
||||
"babel-core": "^7.0.0-bridge",
|
||||
"babel-eslint": "^9.0.0",
|
||||
"babel-jest": "^24.7.1",
|
||||
"babel-loader": "^8.0.4",
|
||||
"cross-env": "^3.1.4",
|
||||
"css-loader": "^1.0.1",
|
||||
|
||||
@@ -160,7 +160,7 @@ describe('ReactTestRendererAsync', () => {
|
||||
|
||||
expect(() =>
|
||||
expect(Scheduler).toFlushAndYieldThrough(['foo', 'baz']),
|
||||
).toThrow('Expected value to equal:');
|
||||
).toThrow('// deep equality');
|
||||
});
|
||||
|
||||
it('toFlushAndYield', () => {
|
||||
@@ -181,7 +181,7 @@ describe('ReactTestRendererAsync', () => {
|
||||
);
|
||||
|
||||
expect(() => expect(Scheduler).toFlushWithoutYielding()).toThrowError(
|
||||
'Expected value to equal:',
|
||||
'// deep equality',
|
||||
);
|
||||
|
||||
renderer.update(
|
||||
@@ -193,7 +193,7 @@ describe('ReactTestRendererAsync', () => {
|
||||
);
|
||||
|
||||
expect(() => expect(Scheduler).toFlushAndYield(['foo', 'baz'])).toThrow(
|
||||
'Expected value to equal:',
|
||||
'// deep equality',
|
||||
);
|
||||
});
|
||||
|
||||
@@ -254,7 +254,7 @@ describe('ReactTestRendererAsync', () => {
|
||||
|
||||
ReactTestRenderer.create(<App />);
|
||||
expect(() => expect(Scheduler).toHaveYielded(['A', 'B'])).toThrow(
|
||||
'Expected value to equal:',
|
||||
'// deep equality',
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ module.exports = {
|
||||
'.*': require.resolve('./preprocessor.js'),
|
||||
},
|
||||
setupFiles: [require.resolve('./setupEnvironment.js')],
|
||||
setupTestFrameworkScriptFile: require.resolve('./setupTests.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'],
|
||||
|
||||
@@ -60,8 +60,9 @@ module.exports = Object.assign({}, baseConfig, {
|
||||
'../../packages/react-devtools-shared/src/__tests__/setupEnv.js'
|
||||
),
|
||||
],
|
||||
// TODO (Jest v24) Rename "setupFilesAfterEnv" after Jest upgrade
|
||||
setupTestFrameworkScriptFile: require.resolve(
|
||||
'../../packages/react-devtools-shared/src/__tests__/setupTests.js'
|
||||
),
|
||||
setupFilesAfterEnv: [
|
||||
require.resolve(
|
||||
'../../packages/react-devtools-shared/src/__tests__/setupTests.js'
|
||||
),
|
||||
],
|
||||
});
|
||||
@@ -62,6 +62,9 @@ module.exports = {
|
||||
if (filePath.match(/\.ts$/) && !filePath.match(/\.d\.ts$/)) {
|
||||
return tsPreprocessor.compile(src, filePath);
|
||||
}
|
||||
if (filePath.match(/\.json$/)) {
|
||||
return src;
|
||||
}
|
||||
if (!filePath.match(/\/third_party\//)) {
|
||||
// for test files, we also apply the async-await transform, but we want to
|
||||
// make sure we don't accidentally apply that transform to product code.
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
'use strict';
|
||||
|
||||
const path = require('path');
|
||||
const pacote = require('pacote');
|
||||
const rimraf = require('rimraf');
|
||||
const prettyFormatPkg = require('pretty-format/package.json');
|
||||
const prettyFormatPkgPath = require.resolve('pretty-format/package.json');
|
||||
|
||||
const reactIsDependencyVersion = prettyFormatPkg.dependencies['react-is'];
|
||||
|
||||
if (!reactIsDependencyVersion) {
|
||||
throw new Error('Unable to find `react-is` dependency in `pretty-format`');
|
||||
}
|
||||
|
||||
const prettyFormatNodeModulesReactIsDir = path.join(
|
||||
path.dirname(prettyFormatPkgPath),
|
||||
'node_modules/react-is'
|
||||
);
|
||||
|
||||
rimraf.sync(prettyFormatNodeModulesReactIsDir);
|
||||
|
||||
pacote
|
||||
.extract(
|
||||
`react-is@${reactIsDependencyVersion}`,
|
||||
prettyFormatNodeModulesReactIsDir
|
||||
)
|
||||
.catch(error => {
|
||||
console.error(error);
|
||||
process.exitCode = 1;
|
||||
});
|
||||
Reference in new issue
Block a user