Skip to content

Commit 95c5afa

Browse files
committed
Updated configs to react 19
1 parent 2df929f commit 95c5afa

File tree

6 files changed

+49
-29
lines changed

6 files changed

+49
-29
lines changed

configs/eslint-config-typescript/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"@monkvision/eslint-config-base": "*",
1616
"@typescript-eslint/eslint-plugin": "^5.43.0",
1717
"@typescript-eslint/parser": "^5.43.0",
18-
"typescript": "^4.8.4"
18+
"typescript": "^5.9.2"
1919
},
2020
"publishConfig": {
2121
"access": "public"

configs/jest-config/base.js

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
1-
const esModules = ['@monkvision/test-utils', 'ky'].join('|');
1+
const esModules = ["@monkvision/test-utils", "ky"].join("|");
22

33
module.exports = (options) => ({
4-
rootDir: './',
5-
roots: options?.monorepo ? ['<rootDir>', '<rootDir>/../../configs/test-utils/src/__mocks__'] : ['<rootDir>'],
6-
preset: 'ts-jest',
7-
testEnvironment: 'node',
8-
testMatch: ['**/test/**/*.test.ts'],
9-
coverageDirectory: 'coverage',
10-
coverageReporters: ['lcov'],
11-
collectCoverageFrom: [
12-
'src/**/*.ts',
13-
],
14-
transformIgnorePatterns: options?.monorepo ? [] : [`node_modules/(?!${esModules})`],
4+
rootDir: "./",
5+
roots: options?.monorepo
6+
? ["<rootDir>", "<rootDir>/../../configs/test-utils/src/__mocks__"]
7+
: ["<rootDir>"],
8+
preset: "ts-jest",
9+
testEnvironment: "node",
10+
testMatch: ["**/test/**/*.test.ts"],
11+
coverageDirectory: "coverage",
12+
coverageReporters: ["lcov"],
13+
collectCoverageFrom: ["src/**/*.ts"],
14+
transformIgnorePatterns: options?.monorepo
15+
? []
16+
: [`node_modules/(?!${esModules})`],
1517
coverageThreshold: {
1618
global: {
1719
branches: 60,
@@ -20,4 +22,4 @@ module.exports = (options) => ({
2022
statements: 60,
2123
},
2224
},
23-
})
25+
});

configs/jest-config/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
const base = require('./base');
2-
const react = require('./react');
1+
const base = require("./base");
2+
const react = require("./react");
33

44
module.exports = {
55
base,

configs/jest-config/setupTests.js

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
1-
const fs = require('fs');
2-
const path = require('path');
1+
const fs = require("fs");
2+
const path = require("path");
33

4-
const mocks = fs.readdirSync(
5-
path.join(__dirname, '..', 'test-utils', 'src', '__mocks__'),
6-
{ recursive: true },
7-
).filter((name) => !name.startsWith('imports') && !name.match(/^@[^/]+$/g))
8-
.map((name) => name.substring(0, name.length - (name.endsWith('x') ? 4 : 3)));
4+
const mocks = fs
5+
.readdirSync(path.join(__dirname, "..", "test-utils", "src", "__mocks__"), {
6+
recursive: true,
7+
})
8+
.filter((name) => !name.startsWith("imports") && !name.match(/^@[^/]+$/g))
9+
.map((name) => name.substring(0, name.length - (name.endsWith("x") ? 4 : 3)));
910

1011
mocks.forEach((mock) => {
11-
jest.mock(mock, () => require('@monkvision/test-utils/src/__mocks__/' + mock));
12+
jest.mock(mock, () =>
13+
require("@monkvision/test-utils/src/__mocks__/" + mock)
14+
);
1215
});

configs/test-utils/package.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@
2828
"@monkvision/jest-config": "5.1.4",
2929
"@monkvision/prettier-config": "5.1.4",
3030
"@monkvision/typescript-config": "5.1.4",
31-
"@testing-library/react": "^12.1.5",
32-
"@testing-library/react-hooks": "^8.0.1",
31+
"@testing-library/react": "^16.3.0",
3332
"@types/jest": "^29.2.2",
3433
"@types/node": "^18.11.9",
3534
"@typescript-eslint/eslint-plugin": "^5.43.0",
@@ -50,8 +49,8 @@
5049
"jest": "^29.3.1",
5150
"mkdirp": "^1.0.4",
5251
"prettier": "^2.7.1",
53-
"react": "^17.0.2",
54-
"react-dom": "^17.0.2",
52+
"react": "^19.1",
53+
"react-dom": "^19.1",
5554
"regexpp": "^3.2.0",
5655
"rimraf": "^3.0.2",
5756
"ts-jest": "^29.0.3",

configs/test-utils/src/expects/props.tsx

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,23 @@ export function expectPropsOnChildMock(
2121
Component: jest.Mock | FC<any> | ForwardedRef<any>,
2222
props: { [key: string]: unknown },
2323
): void {
24-
expect(Component).toHaveBeenCalledWith(expect.objectContaining(props), expect.anything());
24+
const mock = Component as jest.Mock;
25+
expect(mock).toHaveBeenCalled();
26+
27+
const matched = mock.mock.calls.some(([callProps]) =>
28+
expect.objectContaining(props).asymmetricMatch(callProps),
29+
);
30+
31+
if (!matched) {
32+
throw new Error(
33+
`Expected child mock to have been called with props matching ${JSON.stringify(props)},\n` +
34+
`but received calls:\n${JSON.stringify(
35+
mock.mock.calls.map((c) => c[0]),
36+
null,
37+
2,
38+
)}`,
39+
);
40+
}
2541
}
2642

2743
/**

0 commit comments

Comments
 (0)