Skip to content

Commit

Permalink
chore: update to jest 29 (#2048)
Browse files Browse the repository at this point in the history
* chore: update to jest 29

* chore: fix `ts-jest` config is deprecated
  • Loading branch information
ymqy authored Feb 10, 2023
1 parent b873c5d commit bc47801
Show file tree
Hide file tree
Showing 8 changed files with 1,741 additions and 572 deletions.
6 changes: 2 additions & 4 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@ module.exports = {
resetMocks: false,
setupFiles: ['./jest.setup.js', 'jest-localstorage-mock'],
setupFilesAfterEnv: ['@testing-library/jest-dom/extend-expect'],
globals: {
'ts-jest': {
tsconfig: 'tsconfig.json',
},
transform: {
'^.+\\.tsx?$': ['ts-jest', { tsconfig: 'tsconfig.json' }],
},
collectCoverageFrom: [
'<rootDir>/**/src/**/*.{js,jsx,ts,tsx}',
Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"@commitlint/config-conventional": "^17.1.0",
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^13.4.0",
"@types/jest": "^27.4.1",
"@types/jest": "^29.4.0",
"@types/lodash.debounce": "^4.0.6",
"@types/lodash.isequal": "^4.5.5",
"@types/lodash.throttle": "^4.1.6",
Expand All @@ -60,7 +60,8 @@
"gulp-babel": "^8.0.0",
"gulp-typescript": "^6.0.0-alpha.1",
"husky": "^8.0.0",
"jest": "^27.5.1",
"jest": "^29.4.1",
"jest-environment-jsdom": "^29.4.1",
"jest-fetch-mock": "^3.0.3",
"jest-localstorage-mock": "^2.4.18",
"mockjs": "^1.1.0",
Expand All @@ -73,7 +74,7 @@
"react-shadow": "^19.0.3",
"rimraf": "^3.0.2",
"surge": "^0.21.3",
"ts-jest": "^27.1.5",
"ts-jest": "^29.0.5",
"typescript": "^4.8.4",
"umi-request": "^1.2.18",
"webpack": "^4.43.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/hooks/src/useCountDown/__tests__/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const setup = (options: Options = {}) =>

describe('useCountDown', () => {
beforeAll(() => {
jest.useFakeTimers('modern');
jest.useFakeTimers({ legacyFakeTimers: false });
jest.setSystemTime(1479427200000);
});

Expand Down
2 changes: 1 addition & 1 deletion packages/hooks/src/useRafInterval/__tests__/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const setUp = ({ fn, delay, options }: ParamsObj) =>
const FRAME_TIME = 16;
describe('useRafInterval', () => {
beforeAll(() => {
jest.useFakeTimers('modern');
jest.useFakeTimers({ legacyFakeTimers: false });
});
afterAll(() => {
jest.restoreAllMocks();
Expand Down
2 changes: 1 addition & 1 deletion packages/hooks/src/useRafTimeout/__tests__/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const setUp = ({ fn, delay }: ParamsObj) => renderHook(() => useRafTimeout(fn, d
const FRAME_TIME = 16.7;
describe('useRafTimeout', () => {
beforeAll(() => {
jest.useFakeTimers('modern');
jest.useFakeTimers({ legacyFakeTimers: false });
});
afterAll(() => {
jest.restoreAllMocks();
Expand Down
2 changes: 1 addition & 1 deletion packages/hooks/src/useRafTimeout/__tests__/node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const setUp = ({ fn, delay }: ParamsObj) => renderHook(() => useRafTimeout(fn, d
const FRAME_TIME = 16.7;
describe('useRafTimeout', () => {
beforeAll(() => {
jest.useFakeTimers('modern');
jest.useFakeTimers({ legacyFakeTimers: false });
});
afterAll(() => {
jest.restoreAllMocks();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`useResponsive should response to window width changes 1`] = `
Object {
{
"lg": true,
"md": true,
"sm": true,
Expand All @@ -11,7 +11,7 @@ Object {
`;

exports[`useResponsive should response to window width changes 2`] = `
Object {
{
"lg": false,
"md": false,
"sm": false,
Expand All @@ -21,7 +21,7 @@ Object {
`;

exports[`useResponsive should response to window width changes 3`] = `
Object {
{
"lg": false,
"md": false,
"sm": true,
Expand All @@ -31,7 +31,7 @@ Object {
`;

exports[`useResponsive should response to window width changes 4`] = `
Object {
{
"lg": false,
"md": true,
"sm": true,
Expand All @@ -41,7 +41,7 @@ Object {
`;

exports[`useResponsive should response to window width changes 5`] = `
Object {
{
"lg": true,
"md": true,
"sm": true,
Expand All @@ -51,7 +51,7 @@ Object {
`;

exports[`useResponsive should response to window width changes 6`] = `
Object {
{
"lg": true,
"md": true,
"sm": true,
Expand Down
Loading

0 comments on commit bc47801

Please sign in to comment.