Skip to content

Commit eebaa2e

Browse files
fix: upgrade Jest to v30 and unblock jsdom test suites (#1335)
Co-authored-by: acethecreator <devaze007@gmail.com>
1 parent bb682dd commit eebaa2e

6 files changed

Lines changed: 15262 additions & 10681 deletions

File tree

.eslintrc.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
"library/e2e/plugins/index.js",
5454
"library/loaders/remove-hashbag-loader.js",
5555
"library/jest.config.js",
56+
"library/jest.setup.js",
5657
"library/postcss.config.js",
5758
"library/webpack.config.js",
5859
"library/tailwind.config.js",

library/jest.config.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
11
module.exports = {
22
preset: 'ts-jest',
33
testEnvironment: 'node',
4+
// Jest >=28 resolves packages under the `browser` export condition in the
5+
// jsdom environment, which hands us ESM-only browser builds (jsonpath-plus,
6+
// via @stoplight/spectral-core). Keep the Node conditions everywhere so the
7+
// CJS builds are used, as they were before the Jest 26 -> 30 upgrade.
8+
testEnvironmentOptions: {
9+
customExportConditions: ['node', 'node-addons'],
10+
},
411
transform: {
5-
'^.+\\.tsx?$': 'ts-jest',
12+
'^.+\\.tsx?$': ['ts-jest', { tsconfig: 'tsconfig.json' }],
613
},
714

15+
setupFiles: ['<rootDir>/../jest.setup.js'],
16+
817
rootDir: 'src',
918
testMatch: ['**/__tests__/**/*.ts?(x)', '**/?(*.)+(spec|test).ts?(x)'],
10-
11-
globals: {
12-
'ts-jest': {
13-
tsconfig: 'tsconfig.json',
14-
},
15-
},
1619
moduleNameMapper: {
1720
'^nimma/legacy$':
1821
'<rootDir>/../../node_modules/nimma/dist/legacy/cjs/index.js',

library/jest.setup.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
const { TextDecoder, TextEncoder } = require('util');
2+
3+
// jsdom does not implement the Encoding API, so suites using the
4+
// `@jest-environment jsdom` docblock run without TextDecoder/TextEncoder.
5+
// protobufjs v8, pulled in by @asyncapi/protobuf-schema-parser, constructs a
6+
// TextDecoder at module scope, which makes those suites fail to load.
7+
if (typeof global.TextDecoder === 'undefined') {
8+
global.TextDecoder = TextDecoder;
9+
}
10+
if (typeof global.TextEncoder === 'undefined') {
11+
global.TextEncoder = TextEncoder;
12+
}

library/package.json

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,9 @@
6969
},
7070
"dependencies": {
7171
"@asyncapi/avro-schema-parser": "^3.0.24",
72-
"@asyncapi/openapi-schema-parser": "^3.0.24",
73-
"@asyncapi/parser": "^3.6.0",
74-
"@asyncapi/protobuf-schema-parser": "^3.6.0",
72+
"@asyncapi/openapi-schema-parser": "^3.1.0",
73+
"@asyncapi/parser": "^3.6.2",
74+
"@asyncapi/protobuf-schema-parser": "^3.8.2",
7575
"highlight.js": "^10.7.2",
7676
"isomorphic-dompurify": "^2.14.0",
7777
"marked": "^4.0.14",
@@ -90,7 +90,7 @@
9090
"@testing-library/react": "^15.0.4",
9191
"@testing-library/user-event": "^12.8.3",
9292
"@types/dompurify": "^3.0.5",
93-
"@types/jest": "^26.0.23",
93+
"@types/jest": "^30.0.0",
9494
"@types/marked": "^4.0.1",
9595
"@types/node": "^18.0.0",
9696
"@types/react": "^18.2.79",
@@ -100,7 +100,8 @@
100100
"cross-env": "^7.0.3",
101101
"cssnano": "^8.0.2",
102102
"cypress": "^15.19.0",
103-
"jest": "^26.0.0",
103+
"jest": "^30.4.2",
104+
"jest-environment-jsdom": "^30.4.1",
104105
"node-polyfill-webpack-plugin": "^2.0.1",
105106
"postcss": "^8.5.10",
106107
"postcss-cli": "^8.3.1",
@@ -109,7 +110,7 @@
109110
"react": "^18.2.0",
110111
"react-dom": "^18.2.0",
111112
"tailwindcss": "^2.1.1",
112-
"ts-jest": "^26.4.1",
113+
"ts-jest": "^29.4.12",
113114
"ts-loader": "9.4.4",
114115
"webpack": "5.88.2",
115116
"webpack-bundle-analyzer": "4.9.0",

library/src/helpers/__tests__/__snapshots__/schema.test.ts.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Jest Snapshot v1, https://goo.gl/fbAQLP
1+
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
22

33
exports[`SchemaHelpers .applicatorSchemaName should not render title because title is null 1`] = `"first case:"`;
44

0 commit comments

Comments
 (0)