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

Upgrade Jest setup to latest v29 from v26 #820

Merged
merged 5 commits into from
Jun 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion config/jest/babelTransform.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const hasJsxRuntime = (() => {
}
})();

module.exports = babelJest.createTransformer({
module.exports = babelJest.default.createTransformer({
Copy link
Member Author

Choose a reason for hiding this comment

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

presets: [
[
require.resolve('babel-preset-react-app'),
Expand Down
4 changes: 3 additions & 1 deletion config/jest/cssTransform.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@

module.exports = {
process() {
return 'module.exports = {};';
return {
Copy link
Member Author

Choose a reason for hiding this comment

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

code: 'module.exports = {};'
};
},
getCacheKey() {
// The output is always the same.
Expand Down
38 changes: 21 additions & 17 deletions config/jest/fileTransform.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,28 @@ module.exports = {
pascalCase: true,
});
const componentName = `Svg${pascalCaseFilename}`;
return `const React = require('react');
module.exports = {
__esModule: true,
default: ${assetFilename},
ReactComponent: React.forwardRef(function ${componentName}(props, ref) {
return {
$$typeof: Symbol.for('react.element'),
type: 'svg',
ref: ref,
key: null,
props: Object.assign({}, props, {
children: ${assetFilename}
})
};
}),
};`;
return {
code: `const React = require('react');
module.exports = {
__esModule: true,
default: ${assetFilename},
ReactComponent: React.forwardRef(function ${componentName}(props, ref) {
return {
$$typeof: Symbol.for('react.element'),
type: 'svg',
ref: ref,
key: null,
props: Object.assign({}, props, {
children: ${assetFilename}
})
};
}),
};`
};
}

return `module.exports = ${assetFilename};`;
return {
code: `module.exports = ${assetFilename};`
};
},
};
34 changes: 17 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@
]
},
"dependencies": {
"@babel/core": "7.12.3",
"@babel/preset-env": "^7.24.5",
"@material-ui/core": "^4.9.14",
"@material-ui/icons": "^4.9.1",
"@material-ui/lab": "^4.0.0-alpha.54",
Expand All @@ -49,11 +47,6 @@
"auth0-js": "^9.21.0",
"autosize": "^4.0.2",
"axios": "^1.6.2",
"babel-eslint": "^10.1.0",
"babel-jest": "^26.6.0",
"babel-loader": "8.1.0",
"babel-plugin-named-asset-import": "^0.3.7",
"babel-preset-react-app": "^10.0.0",
"bfj": "^7.0.2",
"bootstrap": "4.6.2",
"braft-editor": "^2.3.9",
Expand All @@ -73,10 +66,6 @@
"hls.js": "^1.0.2",
"html-webpack-plugin": "4.5.0",
"identity-obj-proxy": "3.0.0",
"jest": "26.6.0",
"jest-circus": "^26.6.0",
"jest-resolve": "26.6.0",
"jest-watch-typeahead": "0.6.1",
"jquery": "^3.5.1",
"js-file-download": "^0.4.9",
"jspdf": "^2.4.0",
Expand Down Expand Up @@ -147,13 +136,21 @@
"workbox-webpack-plugin": "5.1.4"
},
"devDependencies": {
"@babel/core": "7.12.3",
"@babel/plugin-proposal-private-property-in-object": "^7.21.11",
"@babel/preset-env": "^7.24.5",
"@testing-library/jest-dom": "^6.4.5",
"@testing-library/react": "12.1.5",
"@testing-library/user-event": "14.5.2",
"babel-jest": "^26.6.0",
"babel-eslint": "^10.1.0",
"babel-jest": "^29.7.0",
"babel-loader": "8.1.0",
"babel-plugin-named-asset-import": "^0.3.7",
"babel-preset-react-app": "^10.0.1",
"cross-env": "^7.0.2",
"eslint": "^7.11.0",
"eslint-config-airbnb": "^18.1.0",
"eslint-config-prettier": "^6.11.0",
"eslint-config-react-app": "^6.0.0",
"eslint-plugin-flowtype": "^5.2.0",
"eslint-plugin-import": "^2.22.1",
Expand All @@ -163,9 +160,12 @@
"eslint-plugin-react-hooks": "^4.2.0",
"eslint-plugin-testing-library": "^3.9.2",
"eslint-webpack-plugin": "^2.5.2",
"eslint-config-airbnb": "^18.1.0",
"eslint-config-prettier": "^6.11.0",
"husky": "^4.2.5",
"jest": "^29.7.0",
"jest-circus": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"jest-resolve": "^29.7.0",
"jest-watch-typeahead": "2.2.2",
"lint-staged": "^10.2.4",
"prettier": "^2.0.5",
"pretty-quick": "^2.0.1",
Expand Down Expand Up @@ -203,15 +203,15 @@
},
"transformIgnorePatterns": [
"[/\\\\]node_modules[/\\\\].+\\.(js|jsx|mjs|cjs|ts|tsx)$",
"^.+\\.module\\.(css|sass|scss)$"
"^.+\\.module\\.(css|sass|scss)$",
"node_modules\/(?!axios)"
],
"modulePaths": [
"src"
],
"moduleNameMapper": {
"^react-native$": "react-native-web",
"^.+\\.module\\.(css|sass|scss)$": "identity-obj-proxy",
"^axios$": "axios/dist/node/axios.cjs"
"\\.(css|less|scss)$": "identity-obj-proxy"
},
"moduleFileExtensions": [
"web.js",
Expand Down
Loading