Skip to content

Commit 0e3a9e4

Browse files
committed
BROKEN Upgrade to Jest 28
1 parent 8803f53 commit 0e3a9e4

File tree

15 files changed

+984
-604
lines changed

15 files changed

+984
-604
lines changed

package.json

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,11 @@
6969
"google-closure-compiler": "^20200517.0.0",
7070
"gzip-size": "^5.1.1",
7171
"jasmine-check": "^1.0.0-rc.0",
72-
"jest": "^27.5.1",
73-
"jest-cli": "^27.5.1",
74-
"jest-diff": "^27.5.1",
72+
"jest": "^28.1.3",
73+
"jest-cli": "^28.1.3",
74+
"jest-diff": "^28.1.3",
75+
"jest-environment-jsdom": "^28.1.3",
76+
"jest-jasmine2": "^28.1.3",
7577
"jest-snapshot-serializer-raw": "^1.1.0",
7678
"minimatch": "^3.0.4",
7779
"minimist": "^1.2.3",
@@ -149,5 +151,8 @@
149151
},
150152
"resolutions": {
151153
"react-is": "npm:react-is"
154+
},
155+
"volta": {
156+
"node": "16.17.0"
152157
}
153158
}

packages/jest-mock-scheduler/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
},
2020
"homepage": "https://reactjs.org/",
2121
"peerDependencies": {
22-
"jest": "^23.0.1 || ^24.0.0 || ^25.1.0 || ^26.0.0 || ^27.0.1",
22+
"jest": "^23.0.1 || ^24.0.0 || ^25.1.0 || ^26.0.0 || ^27.0.1 || ^28.0.0",
2323
"scheduler": "^0.20.0"
2424
},
2525
"files": [

packages/jest-react/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
},
2020
"homepage": "https://reactjs.org/",
2121
"peerDependencies": {
22-
"jest": "^23.0.1 || ^24.0.0 || ^25.1.0 || ^26.0.0 || ^27.0.1",
22+
"jest": "^23.0.1 || ^24.0.0 || ^25.1.0 || ^26.0.0 || ^27.0.1 || ^28.0.0",
2323
"react": "^18.2.0",
2424
"react-test-renderer": "^18.2.0"
2525
},

packages/jest-react/src/internalAct.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export function act<T>(scope: () => Thenable<T> | T): Thenable<T> {
3333
if (setTimeout._isMockFunction !== true) {
3434
throw Error(
3535
"This version of `act` requires Jest's timer mocks " +
36-
"(i.e. jest.useFakeTimers('legacy')).",
36+
'(i.e. jest.useFakeTimers({legacyFakeTimers: true})).',
3737
);
3838
}
3939

packages/react-devtools-shared/src/__tests__/setupTests.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ env.beforeEach(() => {
5656
} = require('react-devtools-shared/src/utils');
5757

5858
// Fake timers let us flush Bridge operations between setup and assertions.
59-
jest.useFakeTimers('legacy');
59+
jest.useFakeTimers({legacyFakeTimers: true});
6060

6161
// Use utils.js#withErrorsOrWarningsIgnored instead of directly mutating this array.
6262
global._ignoredErrorOrWarningMessages = [];

packages/react-dom/src/__tests__/ReactErrorBoundaries-test.internal.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ describe('ReactErrorBoundaries', () => {
3737
let Normal;
3838

3939
beforeEach(() => {
40-
jest.useFakeTimers('legacy');
40+
jest.useFakeTimers({legacyFakeTimers: true});
4141
jest.resetModules();
4242
PropTypes = require('prop-types');
4343
ReactFeatureFlags = require('shared/ReactFeatureFlags');

packages/react-dom/src/__tests__/ReactTestUtilsAct-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ function runActTests(label, render, unmount, rerender) {
302302

303303
describe('fake timers', () => {
304304
beforeEach(() => {
305-
jest.useFakeTimers('legacy');
305+
jest.useFakeTimers({legacyFakeTimers: true});
306306
});
307307

308308
afterEach(() => {

packages/react-reconciler/src/__tests__/ReactEffectOrdering-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ let useLayoutEffect;
2222
describe('ReactHooksWithNoopRenderer', () => {
2323
beforeEach(() => {
2424
jest.resetModules();
25-
jest.useFakeTimers('legacy');
25+
jest.useFakeTimers({legacyFakeTimers: true});
2626

2727
React = require('react');
2828
ReactNoop = require('react-noop-renderer');

packages/react-reconciler/src/__tests__/ReactHooksWithNoopRenderer-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ let SuspenseList;
3939
describe('ReactHooksWithNoopRenderer', () => {
4040
beforeEach(() => {
4141
jest.resetModules();
42-
jest.useFakeTimers('legacy');
42+
jest.useFakeTimers({legacyFakeTimers: true});
4343

4444
React = require('react');
4545
ReactNoop = require('react-noop-renderer');

packages/react-reconciler/src/__tests__/useMutableSource-test.internal.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ let useMutableSource;
2222

2323
function loadModules() {
2424
jest.resetModules();
25-
jest.useFakeTimers('legacy');
25+
jest.useFakeTimers({legacyFakeTimers: true});
2626

2727
ReactFeatureFlags = require('shared/ReactFeatureFlags');
2828
ReactFeatureFlags.enableProfilerTimer = true;

packages/react-reconciler/src/__tests__/useRef-test.internal.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ describe('useRef', () => {
4545
}
4646

4747
it('creates a ref object initialized with the provided value', () => {
48-
jest.useFakeTimers('legacy');
48+
jest.useFakeTimers({legacyFakeTimers: true});
4949

5050
function useDebouncedCallback(callback, ms, inputs) {
5151
const timeoutID = useRef(-1);

packages/scheduler/src/__tests__/SchedulerSetTimeout-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ describe('SchedulerNoDOM', () => {
2121
// This is only meant to be used for testing purposes, like with jest's fake timer API.
2222
beforeEach(() => {
2323
jest.resetModules();
24-
jest.useFakeTimers('legacy');
24+
jest.useFakeTimers({legacyFakeTimers: true});
2525
delete global.setImmediate;
2626
jest.unmock('scheduler');
2727

scripts/jest/config.base.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ module.exports = {
2121
roots: ['<rootDir>/packages', '<rootDir>/scripts'],
2222
collectCoverageFrom: ['packages/**/*.js'],
2323
// TODO: Use the default `modern` implementation (includes `jest.useFakeTimers()`)
24-
timers: 'legacy',
24+
fakeTimers: {
25+
enableGlobally: true,
26+
legacyFakeTimers: true,
27+
},
2528
snapshotSerializers: [require.resolve('jest-snapshot-serializer-raw')],
2629

2730
testSequencer: require.resolve('./jestSequencer'),

scripts/jest/preprocessor.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,16 +57,16 @@ module.exports = {
5757
process: function(src, filePath) {
5858
if (filePath.match(/\.css$/)) {
5959
// Don't try to parse CSS modules; they aren't needed for tests anyway.
60-
return '';
60+
return {code: ''};
6161
}
6262
if (filePath.match(/\.coffee$/)) {
63-
return coffee.compile(src, {bare: true});
63+
return {code: coffee.compile(src, {bare: true})};
6464
}
6565
if (filePath.match(/\.ts$/) && !filePath.match(/\.d\.ts$/)) {
66-
return tsPreprocessor.compile(src, filePath);
66+
return {code: tsPreprocessor.compile(src, filePath)};
6767
}
6868
if (filePath.match(/\.json$/)) {
69-
return src;
69+
return {code: src};
7070
}
7171
if (!filePath.match(/\/third_party\//)) {
7272
// for test files, we also apply the async-await transform, but we want to
@@ -100,7 +100,7 @@ module.exports = {
100100
)
101101
);
102102
}
103-
return src;
103+
return {code: src};
104104
},
105105

106106
getCacheKey: createCacheKeyFunction([

0 commit comments

Comments
 (0)