Skip to content

Commit

Permalink
test: Adjust Jest config to properly transform all ESM packages
Browse files Browse the repository at this point in the history
Signed-off-by: Ferdinand Thiessen <[email protected]>
  • Loading branch information
susnux committed Jul 26, 2024
1 parent 9002461 commit a1cc078
Show file tree
Hide file tree
Showing 4 changed files with 160 additions and 1 deletion.
10 changes: 10 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@ module.exports = {
plugins: [
'@babel/plugin-syntax-dynamic-import',
'@babel/plugin-proposal-class-properties',
// We need the bundler entry not the web one
// Jest will otherwise resolve the wrong one
[
"module-resolver",
{
"alias": {
"webdav$": "webdav/dist/node/index.js",
},
},
]
],
presets: [
// https://babeljs.io/docs/en/babel-preset-typescript
Expand Down
5 changes: 4 additions & 1 deletion jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,15 @@ const ignorePatterns = [
'@buttercup/fetch',
'@juliushaertl',
'@mdi/svg',
'@nextcloud/files',
'@nextcloud/upload',
'@nextcloud/vue',
'ansi-regex',
'camelcase',
'char-regex',
'hot-patcher',
'is-svg',
'layerr',
'mime',
'p-cancelable',
'p-limit',
Expand All @@ -43,6 +45,7 @@ const ignorePatterns = [
'strip-ansi',
'tributejs',
'unist-.+',
'url-join',
'vue-material-design-icons',
'webdav',
'yocto-queue',
Expand All @@ -66,7 +69,7 @@ const config: Config = {

transform: {
// process `*.js` files with `babel-jest`
'^.+\\.js$': 'babel-jest',
'^.+\\.c?js$': 'babel-jest',
'^.+\\.vue$': '@vue/vue2-jest',
'^.+\\.ts$': ['ts-jest', {
// @see https://github.com/kulshekhar/ts-jest/issues/4081
Expand Down
145 changes: 145 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@
"babel-jest": "^29.6.4",
"babel-loader": "^9.1.0",
"babel-loader-exclude-node-modules-except": "^1.2.1",
"babel-plugin-module-resolver": "^5.0.2",
"colord": "^2.9.3",
"css-loader": "^6.8.1",
"cypress": "^13.7.3",
Expand Down

0 comments on commit a1cc078

Please sign in to comment.