MT#64314 Fix jest tests

* Add testEnvironment: 'jsdom' to provide browser-like
  globals (DOM APIs) that Vue and test-utils need
* Add explicit module path mapping in jest.config.js
  to force Jest to use the CommonJS bundle instead of
  the browser bundle.

Change-Id: I659b122ed3884c229b5f6dab1f08e135bcb8c03d
master
Debora Crescenzo 1 week ago
parent 6f57bd1628
commit 04c3d71f53

@ -1,6 +1,7 @@
const esModules = ['quasar/lang', 'lodash-es', 'quasar'].join('|')
module.exports = {
testEnvironment: 'jsdom',
globals: {
__DEV__: true
},
@ -41,6 +42,7 @@ module.exports = {
],
moduleNameMapper: {
'^vue$': 'vue',
'^@vue/test-utils$': '<rootDir>/node_modules/@vue/test-utils/dist/vue-test-utils.cjs.js',
'^test-utils$': '@vue/test-utils',
// '^quasar$': '<rootDir>/node_modules/quasar/dist/quasar.common.js',
'^~/(.*)$': '<rootDir>/$1',

@ -2,6 +2,9 @@
// console.log = jest.fn(() => { throw new Error('Do not use console.log() in production') })
jest.setTimeout(1000)
// Make Vue available globally for @vue/test-utils
global.Vue = require('vue')
// jest speedup when errors are part of the game
// Error.stackTraceLimit = 0

Loading…
Cancel
Save