Skip to content

Commit

Permalink
chore: Upgrade Jest packages to latest versions in /ui
Browse files Browse the repository at this point in the history
This is preparatory work to upgrade msw, which proved out to be
impossible to do (at least for me) with older versions of Jest.

Notes about the changes:

- The syntax for Jest transformers has changed, updated cssTransform.js
  accordingly

- By default, Jest doesn't transform files in node_modules (anymore?),
  but we need to transpile ES module dependencies to CommonJS because
  Jest can't handle ESM, so we need to un-ignore them in
  `transformIgnorePatterns` in the Jest config

- The transitive nwsapi dependency needs to be pinned to an older
  version in package.json since the newest versions fail to parse some
  CSS class names that Elastic UI generates. This workaround was
  suggested in dperini/nwsapi#139 (comment)

Signed-off-by: Harri Lehtola <peruukki@hotmail.com>
  • Loading branch information
peruukki committed Jan 29, 2025
1 parent 6ce08d3 commit 0c72b33
Show file tree
Hide file tree
Showing 4 changed files with 847 additions and 704 deletions.
2 changes: 1 addition & 1 deletion ui/config/jest/cssTransform.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

module.exports = {
process() {
return 'module.exports = {};';
return { code: 'module.exports = {};' };
},
getCacheKey() {
// The output is always the same.
Expand Down
4 changes: 3 additions & 1 deletion ui/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const esModules = ['@elastic/eui', 'uuid'];

module.exports = {
roots: ["<rootDir>/src"],
collectCoverageFrom: ["src/**/*.{js,jsx,ts,tsx}", "!src/**/*.d.ts"],
Expand All @@ -15,7 +17,7 @@ module.exports = {
"<rootDir>/config/jest/fileTransform.js",
},
transformIgnorePatterns: [
"[/\\\\]node_modules[/\\\\].+\\.(js|jsx|mjs|cjs|ts|tsx)$",
`[/\\\\]node_modules[/\\\\](?!(${esModules.map(name => name.replaceAll('/', '[/\\\\]')).join('|')})[/\\\\])`,
"^.+\\.module\\.(css|sass|scss)$",
],
modulePaths: [],
Expand Down
10 changes: 7 additions & 3 deletions ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,10 @@
"fs-extra": "^10.0.0",
"html-webpack-plugin": "^5.5.0",
"identity-obj-proxy": "^3.0.0",
"jest": "^27.4.3",
"jest-resolve": "^27.4.2",
"jest-watch-typeahead": "^1.0.0",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"jest-resolve": "^29.7.0",
"jest-watch-typeahead": "^2.2.2",
"mini-css-extract-plugin": "^2.4.5",
"msw": "^0.36.8",
"postcss": "^8.4.4",
Expand Down Expand Up @@ -126,6 +127,9 @@
"webpack-manifest-plugin": "^4.0.2",
"workbox-webpack-plugin": "^6.4.1"
},
"resolutions": {
"nwsapi": "2.2.13"
},
"description": "Web UI for the [Feast Feature Store](https://feast.dev/)",
"repository": {
"type": "git",
Expand Down
Loading

0 comments on commit 0c72b33

Please sign in to comment.