diff options
author | julia.kirschenheuter <julia.kirschenheuter@nextcloud.com> | 2022-06-15 17:42:23 +0300 |
---|---|---|
committer | julia.kirschenheuter <julia.kirschenheuter@nextcloud.com> | 2022-06-15 18:08:13 +0300 |
commit | 903a2a10854229b1e721eaf0279ab903a63ee659 (patch) | |
tree | 5e050f7cd79a73c43259a2c69b4b2e39905f12c6 /jest.config.js | |
parent | e35e9e0a74947aea220353642469200ae286a361 (diff) |
Update Jest to version 28: @vue/vue2-jest, babel-jest, jestdependajulia/npm_and_yarn/jest-28
Remove package "@vue/cli-plugin-unit-jest": this one had dependency to @vue/vue2-jest 27. This plugin is not needed anymore.
Move configuration from node_modules/@vue/cli-plugin-unit-jest/presets/default/jest-preset.js to jest.config.js
Install all needed packages: jest-serializer-vue, jest-transform-stub, jest-watch-typeahead, @types/jest.
jest.config.js: Update testEnvironment from 'jsdom' to 'jest-environment-jsdom', see https://jestjs.io/docs/upgrading-to-jest28#jsdom.
Install "jest-environment-jsdom" because of Jest 28.
Cleanup jest.config.js.
Signed-off-by: julia.kirschenheuter <julia.kirschenheuter@nextcloud.com>
Diffstat (limited to 'jest.config.js')
-rw-r--r-- | jest.config.js | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/jest.config.js b/jest.config.js index 3514070fd..e7cef3325 100644 --- a/jest.config.js +++ b/jest.config.js @@ -1,5 +1,39 @@ module.exports = { - preset: '@vue/cli-plugin-unit-jest/presets/no-babel', + testEnvironment: 'jest-environment-jsdom', + moduleFileExtensions: [ + 'js', + 'jsx', + 'json', + // tell Jest to handle *.vue files + 'vue', + ], + transform: { + // process *.vue files with vue-jest + '^.+\\.vue$': require.resolve('@vue/vue2-jest'), + '.+\\.(css|styl|less|sass|scss|jpg|jpeg|png|svg|gif|eot|otf|webp|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga|avif)$': + require.resolve('jest-transform-stub'), + '^.+\\.jsx?$': require.resolve('babel-jest'), + }, + // support the same @ -> src alias mapping in source code + moduleNameMapper: { + '^@/(.*)$': '<rootDir>/src/$1', + }, + // serializer for snapshots + snapshotSerializers: [ + 'jest-serializer-vue', + ], + testMatch: [ + '**/tests/unit/**/*.spec.[jt]s?(x)', + '**/__tests__/*.[jt]s?(x)', + ], + // https://github.com/facebook/jest/issues/6766 + testEnvironmentOptions: { + url: 'http://localhost/', + }, + watchPlugins: [ + require.resolve('jest-watch-typeahead/filename'), + require.resolve('jest-watch-typeahead/testname'), + ], transformIgnorePatterns: ['/node_modules/(?!@ckeditor)/.+\\.js$'], setupFiles: [ '<rootDir>/src/tests/setup.js', |