Skip to content

Commit 67a0bec

Browse files
committed
chore: upgrade Jest from v27 to v29
Fixes CI failure where react-native's jest-environment-node@29 was getting hoisted over Jest 27's version, causing a config format mismatch. - Update jest, babel-jest, jest-environment-jsdom, pretty-format to v29 - Add transformIgnorePatterns to preact config for ESM compat - Fix console.error filter for jsdom 20 Error objects - Add --silent/--quiet/--reporter=dot flags for cleaner test output - Update snapshots for pretty-format v29 formatting
1 parent 8cdc898 commit 67a0bec

9 files changed

Lines changed: 690 additions & 719 deletions

File tree

.jest.preact.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,8 @@
55
"setupFilesAfterEnv": ["<rootDir>/test/preact/setup.js"],
66
"snapshotSerializers": ["enzyme-to-json/serializer"],
77
"testEnvironment": "jsdom",
8-
"testRegex": "test/preact/.*\\.spec\\.js$"
8+
"testRegex": "test/preact/.*\\.spec\\.js$",
9+
"transformIgnorePatterns": [
10+
"/node_modules/(?!(.pnpm/.*/)?(preact)/)"
11+
]
912
}

package.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,36 +25,36 @@
2525
"license": "MIT",
2626
"scripts": {
2727
"test": "pnpm test:web && pnpm test:native && pnpm test:preact && pnpm test:vitest && pnpm lint:pkg",
28-
"test:web": "jest --color",
28+
"test:web": "jest --color --silent",
2929
"test:web:watch": "jest --watch",
30-
"test:native": "jest --color --config .jest.native.json",
31-
"test:preact": "jest --color --config .jest.preact.json",
30+
"test:native": "jest --color --silent --config .jest.native.json",
31+
"test:preact": "jest --color --silent --config .jest.preact.json",
3232
"test:vitest": "pnpm --filter vitest-entry test",
33-
"lint:pkg": "publint --pack npm && attw --pack .",
33+
"lint:pkg": "publint --pack npm && attw --pack . --quiet",
3434
"prepare": "husky"
3535
},
3636
"devDependencies": {
3737
"@arethetypeswrong/cli": "^0.18.2",
3838
"@babel/core": "^7.0.0",
39+
"@babel/plugin-transform-flow-strip-types": "^7.0.0",
3940
"@babel/preset-env": "^7.16.4",
4041
"@babel/preset-react": "^7.0.0",
4142
"@biomejs/biome": "^2.4.8",
43+
"@cfaester/enzyme-adapter-react-18": "^0.8.0",
4244
"@changesets/changelog-git": "^0.2.1",
4345
"@changesets/cli": "^2.30.0",
4446
"@testing-library/react": "^12.1.2",
45-
"@babel/plugin-transform-flow-strip-types": "^7.0.0",
46-
"@cfaester/enzyme-adapter-react-18": "^0.8.0",
47-
"babel-jest": "^27.3.1",
47+
"babel-jest": "^29.7.0",
4848
"enzyme": "^3.6.0",
4949
"enzyme-adapter-preact-pure": "^3.3.0",
5050
"enzyme-to-json": "^3.3.1",
5151
"husky": "^9.1.7",
52-
"jest": "^27.3.1",
53-
"jest-environment-jsdom": "^27.5.1",
52+
"jest": "^29.7.0",
53+
"jest-environment-jsdom": "^29.7.0",
5454
"lint-staged": "^15.5.2",
5555
"preact": "^10.0.0-beta.2",
5656
"preact-render-to-json": "^3.6.6",
57-
"pretty-format": "^27.5.1",
57+
"pretty-format": "^29.7.0",
5858
"publint": "^0.3.18",
5959
"react": "18.2.0",
6060
"react-dom": "18.2.0",

pnpm-lock.yaml

Lines changed: 568 additions & 626 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/__snapshots__/styleSheetSerializer.spec.js.snap

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -789,7 +789,7 @@ exports[`referring to other components: mount 1`] = `
789789
}
790790
791791
.c5::before {
792-
content: '';
792+
content: "";
793793
margin: 0 10px;
794794
}
795795
@@ -879,7 +879,7 @@ exports[`referring to other components: react-test-renderer 1`] = `
879879
}
880880
881881
.c5::before {
882-
content: '';
882+
content: "";
883883
margin: 0 10px;
884884
}
885885
@@ -953,7 +953,7 @@ exports[`referring to other components: react-testing-library 1`] = `
953953
}
954954
955955
.c5::before {
956-
content: '';
956+
content: "";
957957
margin: 0 10px;
958958
}
959959
@@ -1353,7 +1353,7 @@ exports[`theming: mount 1`] = `
13531353
<div>
13541354
<styled.button
13551355
theme={
1356-
Object {
1356+
{
13571357
"main": "palevioletred",
13581358
}
13591359
}
@@ -1366,14 +1366,14 @@ exports[`theming: mount 1`] = `
13661366
</styled.button>
13671367
<Component
13681368
theme={
1369-
Object {
1369+
{
13701370
"main": "mediumseagreen",
13711371
}
13721372
}
13731373
>
13741374
<styled.button
13751375
theme={
1376-
Object {
1376+
{
13771377
"main": "palevioletred",
13781378
}
13791379
}
@@ -1458,7 +1458,7 @@ exports[`theming: shallow 1`] = `
14581458
<div>
14591459
<styled.button
14601460
theme={
1461-
Object {
1461+
{
14621462
"main": "palevioletred",
14631463
}
14641464
}
@@ -1467,14 +1467,14 @@ exports[`theming: shallow 1`] = `
14671467
</styled.button>
14681468
<Component
14691469
theme={
1470-
Object {
1470+
{
14711471
"main": "mediumseagreen",
14721472
}
14731473
}
14741474
>
14751475
<styled.button
14761476
theme={
1477-
Object {
1477+
{
14781478
"main": "palevioletred",
14791479
}
14801480
}

test/__snapshots__/toHaveStyleRule.spec.js.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ exports[`message when rules not found 1`] = `"No style rules found on passed Com
44

55
exports[`message when rules not found using options 1`] = `
66
"No style rules found on passed Component using options:
7-
{\\"media\\":\\"(max-width:640px)\\",\\"modifier\\":\\":hover\\"}"
7+
{"media":"(max-width:640px)","modifier":":hover"}"
88
`;
99

1010
exports[`non existing 1`] = `"No style rules found on passed Component"`;
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

33
exports[`message when property not found 1`] = `
4-
"[31m\\"Property 'color' not found in style rules\\"[39m
4+
"[31m"Property 'color' not found in style rules"[39m
55
66
Expected
7-
[32m\\"color: black\\"[39m
7+
[32m"color: black"[39m
88
Received:
9-
[31m\\"color: undefined\\"[39m"
9+
[31m"color: undefined"[39m"
1010
`;
1111

1212
exports[`message when value does not match 1`] = `
13-
"[31m\\"Value mismatch for property 'background-color'\\"[39m
13+
"[31m"Value mismatch for property 'background-color'"[39m
1414
1515
Expected
16-
[32m\\"background-color: red\\"[39m
16+
[32m"background-color: red"[39m
1717
Received:
18-
[31m\\"background-color: orange\\"[39m"
18+
[31m"background-color: orange"[39m"
1919
`;

test/setup.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ configure({ adapter: new Adapter() });
88
// Suppress expected noise from React dev warnings and jsdom CSS parsing
99
const originalConsoleError = console.error;
1010
console.error = (...args) => {
11-
if (typeof args[0] === 'string' && (
12-
args[0].startsWith('Warning:') ||
13-
args[0].includes('Could not parse CSS stylesheet')
14-
)) return;
11+
const msg = args[0] instanceof Error ? args[0].message : String(args[0]);
12+
if (
13+
msg.startsWith('Warning:') ||
14+
msg.includes('Could not parse CSS stylesheet')
15+
) return;
1516
originalConsoleError.call(console, ...args);
1617
};

0 commit comments

Comments
 (0)