Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build: Upgrade Jest to 29 #19863

Merged
merged 11 commits into from
Nov 17, 2022
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ jobs:
name: Test
command: |
cd code
yarn test --coverage --ci --runInBand
yarn test --coverage --ci --maxWorkers=6
- store_test_results:
path: code/junit.xml
- persist_to_workspace:
Expand Down
2 changes: 1 addition & 1 deletion code/addons/docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
},
"dependencies": {
"@babel/plugin-transform-react-jsx": "^7.19.0",
"@jest/transform": "^28.0.0",
"@jest/transform": "^29.3.1",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kasperpeulen I see that you updated @jest/transform here and in storyshots. Was that intentional? This is a dependency that is used by addon-docs, and my storybook is now crashing with an error message coming from jest-util via @jest/transform.

Uncaught TypeError: Cannot read properties of undefined (reading 'isTTY')
    at ./node_modules/jest-util/build/isInteractive.js 

Seems to come from https://github.com/facebook/jest/blob/e7edb75f8357090714213f252c5aaaa9b3c29f5f/packages/jest-util/src/isInteractive.ts#L10. We can't run that in the browser, since process isn't defined there.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm... intentional in the sense that I thought it would be nice to upgrade all the jest-related deps from 28 to 29, but I don't know about this package. So downgrading seems fine to me.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be trivial to replace process with a fake object for browser usage, no?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm sure we can deal with it, yes. I just like to keep user facing changes separate from internal test updates.

@SimenB since you're here, is this something that changed from 28 to 29? I took a quick look and couldn't immediately figure out why this would start to fail now in 29. Maybe you know offhand?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, I upgraded to the latest beta (beta.8), and I no longer get this error. I guess we can just keep our eyes out for it again.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing comes to mind, that code has been the same for years

"@mdx-js/react": "^2.1.5",
"@storybook/blocks": "7.0.0-alpha.50",
"@storybook/components": "7.0.0-alpha.50",
Expand Down
2 changes: 1 addition & 1 deletion code/addons/interactions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
"@storybook/theming": "7.0.0-alpha.50",
"@storybook/types": "7.0.0-alpha.50",
"global": "^4.4.0",
"jest-mock": "^27.0.6",
"jest-mock": "^29.3.1",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we can update this, since it's an actual dependency that is used by the interactions addon, and so far it only supports jest 27, AFAIK

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aha, will downgrade, cc @yannbf

"polished": "^4.2.2",
"ts-dedent": "^2.2.0"
},
Expand Down
4 changes: 2 additions & 2 deletions code/addons/storyshots/storyshots-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"storybook": "yarn sb dev -p 6006"
},
"dependencies": {
"@jest/transform": "^28.0.0",
"@jest/transform": "^29.3.1",
"@storybook/addons": "7.0.0-alpha.50",
"@storybook/babel-plugin-require-context-hook": "1.0.1",
"@storybook/client-api": "7.0.0-alpha.50",
Expand All @@ -46,7 +46,7 @@
"@storybook/core-webpack": "7.0.0-alpha.50",
"@storybook/types": "7.0.0-alpha.50",
"@types/glob": "^7.1.3",
"@types/jest-specific-snapshot": "^0.5.3",
"@types/jest-specific-snapshot": "^0.5.6",
"core-js": "^3.8.2",
"glob": "^7.1.6",
"global": "^4.4.0",
Expand Down
4 changes: 2 additions & 2 deletions code/addons/storyshots/storyshots-puppeteer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
"@storybook/csf": "0.0.2-next.7",
"@storybook/node-logger": "7.0.0-alpha.50",
"@storybook/types": "7.0.0-alpha.50",
"@types/jest-image-snapshot": "^4.1.3",
"jest-image-snapshot": "^4.3.0"
"@types/jest-image-snapshot": "^5.1.0",
"jest-image-snapshot": "^6.0.0"
},
"devDependencies": {
"@types/puppeteer": "^5.4.0",
Expand Down
2 changes: 1 addition & 1 deletion code/frameworks/angular/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
"@types/rimraf": "^3.0.2",
"@types/tmp": "^0.2.3",
"cross-spawn": "^7.0.3",
"jest": "^28.0.0",
"jest": "^29.3.1",
"jest-preset-angular": "^12.0.0",
"jest-specific-snapshot": "^6.0.0",
"rimraf": "^3.0.2",
Expand Down
12 changes: 0 additions & 12 deletions code/jest.config.base.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,6 @@ module.exports = {
'/renderers/vue3/src/public-types.test.ts',
...(process.platform === 'win32' ? skipOnWindows : []),
],
collectCoverage: false,
collectCoverageFrom: [
'frameworks/*/src/**/*.{js,jsx,ts,tsx}',
'lib/*/src/**/*.{js,jsx,ts,tsx}',
'renderers/*/src/**/*.{js,jsx,ts,tsx}',
'addons/*/src/**/*.{js,jsx,ts,tsx}',
'ui/*/src/**/*.{js,jsx,ts,tsx}',
],
coveragePathIgnorePatterns: [
'/node_modules/',
'/cli/test/',
Expand All @@ -85,8 +77,6 @@ module.exports = {
SNAPSHOT_OS: os.platform() === 'win32' ? 'windows' : 'posix',
},
snapshotSerializers: ['@emotion/jest/serializer', 'jest-serializer-html'],
coverageDirectory: 'coverage',
coverageReporters: ['lcov'],
testEnvironmentOptions: {
url: 'http://localhost',
},
Expand All @@ -97,8 +87,6 @@ module.exports = {
'/template/',
],
moduleFileExtensions: ['js', 'jsx', 'ts', 'tsx', 'json', 'node'],
watchPlugins: ['jest-watch-typeahead/filename', 'jest-watch-typeahead/testname'],
reporters: ['default', 'jest-junit'],
snapshotFormat: {
escapeString: true,
printBasicPrototype: true,
Expand Down
12 changes: 12 additions & 0 deletions code/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,16 @@ module.exports = {
'<rootDir>/renderers/*',
'<rootDir>/ui/*',
],
collectCoverage: false,
collectCoverageFrom: [
'frameworks/*/src/**/*.{js,jsx,ts,tsx}',
'lib/*/src/**/*.{js,jsx,ts,tsx}',
'renderers/*/src/**/*.{js,jsx,ts,tsx}',
'addons/*/src/**/*.{js,jsx,ts,tsx}',
'ui/*/src/**/*.{js,jsx,ts,tsx}',
],
coverageDirectory: 'coverage',
coverageReporters: ['lcov'],
reporters: ['default', 'jest-junit'],
watchPlugins: ['jest-watch-typeahead/filename', 'jest-watch-typeahead/testname'],
};
2 changes: 1 addition & 1 deletion code/lib/codemod/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"util": "^0.12.4"
},
"devDependencies": {
"jest": "^28.0.0",
"jest": "^29.3.1",
"jest-specific-snapshot": "^6.0.0",
"typescript": "^4.9.3"
},
Expand Down
2 changes: 1 addition & 1 deletion code/lib/postinstall/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"prep": "../../../scripts/prepare/bundle.ts"
},
"devDependencies": {
"jest": "^28.0.0",
"jest": "^29.3.1",
"jest-specific-snapshot": "^6.0.0",
"jscodeshift": "^0.13.1",
"typescript": "^4.9.3"
Expand Down
16 changes: 8 additions & 8 deletions code/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@
"@compodoc/compodoc": "^1.1.18",
"@emotion/babel-plugin": "^11.10.2",
"@emotion/jest": "^11.10.0",
"@jest/globals": "^28.0.0",
"@jest/globals": "^29.3.1",
"@linear/sdk": "^1.21.0",
"@nrwl/cli": "14.6.1",
"@nrwl/nx-cloud": "14.6.0",
Expand Down Expand Up @@ -260,7 +260,7 @@
"@vitejs/plugin-react": "^2.1.0",
"babel-core": "^7.0.0-bridge.0",
"babel-eslint": "^10.1.0",
"babel-jest": "^28.1.3",
"babel-jest": "^29.3.1",
"babel-loader": "^8.3.0",
"babel-plugin-add-react-displayname": "^0.0.5",
"babel-plugin-dynamic-import-node": "^2.3.3",
Expand Down Expand Up @@ -292,13 +292,13 @@
"global": "^4.4.0",
"http-server": "^0.12.3",
"husky": "^4.3.7",
"jest": "^28.0.0",
"jest-environment-jsdom": "^28.0.0",
"jest-image-snapshot": "^4.3.0",
"jest-junit": "^13.0.0",
"jest": "^29.3.1",
"jest-environment-jsdom": "^29.3.1",
"jest-image-snapshot": "^6.0.0",
"jest-junit": "^14.0.1",
"jest-os-detection": "^1.3.1",
"jest-serializer-html": "^7.0.0",
"jest-watch-typeahead": "^0.6.1",
"jest-serializer-html": "^7.1.0",
"jest-watch-typeahead": "^2.2.1",
"js-yaml": "^3.14.1",
"lerna": "^3.22.1",
"lint-staged": "^10.5.4",
Expand Down
2 changes: 1 addition & 1 deletion code/renderers/vue3/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
},
"devDependencies": {
"@digitak/esrun": "^3.2.2",
"@vue/vue3-jest": "28",
"@vue/vue3-jest": "29",
"typescript": "^4.9.3",
"vue": "^3.2.41",
"vue-tsc": "^1.0.8"
Expand Down
Loading