Skip to content

Commit d97ffa1

Browse files
committed
update testing dependencies
1 parent ec1e1da commit d97ffa1

6 files changed

Lines changed: 1070 additions & 1989 deletions

File tree

.babelrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"presets": ["next/babel"]
3+
}

jest.config.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
module.exports = {
22
roots: ['<rootDir>'],
3+
preset: 'ts-jest',
4+
testEnvironment: 'jsdom',
35
moduleFileExtensions: ['ts', 'tsx', 'js', 'json', 'jsx'],
46
testPathIgnorePatterns: ['<rootDir>[/\\\\](node_modules|.next)[/\\\\]'],
57
transformIgnorePatterns: ['[/\\\\]node_modules[/\\\\].+\\.(ts|tsx)$'],

package.json

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
},
4949
"dependencies": {
5050
"@ant-design/icons": "^4.3.0",
51+
"@testing-library/dom": "^10.4.0",
5152
"@types/socket.io": "^2.1.11",
5253
"antd": "^5.23.3",
5354
"basic-auth": "^2.0.1",
@@ -66,26 +67,28 @@
6667
"sequelize": "^6.37.5",
6768
"socket.io": "^3.0.3",
6869
"socket.io-client": "^3.0.3",
70+
"ts-jest": "^29.2.5",
6971
"tsscmp": "^1.0.6",
7072
"uuid": "^8.3.1"
7173
},
7274
"devDependencies": {
73-
"@testing-library/jest-dom": "^5.11.5",
74-
"@testing-library/react": "^10.0.1",
75+
"@testing-library/jest-dom": "^6.6.3",
76+
"@testing-library/react": "^16.2.0",
7577
"@types/basic-auth": "^1.1.3",
76-
"@types/jest": "^25.1.4",
77-
"@types/node": "^13.9.5",
78+
"@types/jest": "^29.5.14",
79+
"@types/node": "^22.13.1",
7880
"@types/react": "^19.0.8",
7981
"@typescript-eslint/eslint-plugin": "^2.25.0",
8082
"@typescript-eslint/parser": "^2.25.0",
81-
"babel-jest": "^25.2.3",
83+
"babel-jest": "^29.7.0",
8284
"eslint": "^6.8.0",
8385
"eslint-config-prettier": "^6.10.1",
8486
"eslint-plugin-prettier": "^3.1.4",
8587
"eslint-plugin-react": "^7.19.0",
8688
"husky": "^4.3.0",
8789
"identity-obj-proxy": "^3.0.0",
88-
"jest": "^25.2.3",
90+
"jest": "^29.7.0",
91+
"jest-environment-jsdom": "^29.7.0",
8992
"jest-watch-typeahead": "^0.5.0",
9093
"lint-staged": "^10.0.10",
9194
"nodemon": "^2.0.6",

test/setupTests.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,20 @@
1-
import '@testing-library/jest-dom';
1+
require('@testing-library/jest-dom');
2+
import { useRouter } from 'next/router';
3+
4+
jest.mock('next/router', () => ({
5+
useRouter: jest.fn(),
6+
}));
7+
8+
const mockedUseRouter = useRouter as jest.Mock;
9+
10+
beforeEach(() => {
11+
mockedUseRouter.mockReturnValue({
12+
route: '/',
13+
pathname: '/',
14+
query: {},
15+
asPath: '/',
16+
});
17+
});
218

319
global.fetch = jest.fn();
420

tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
"isolatedModules": true,
1515
"jsx": "preserve",
1616
"useDefineForClassFields": true,
17-
"incremental": true
17+
"incremental": true,
18+
"types": ["@testing-library/jest-dom"]
1819
},
1920
"exclude": ["node_modules", ".next", "out"],
2021
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", "**/*.js"]

0 commit comments

Comments
 (0)