2022-03-11 10:25:30 +00:00
|
|
|
const esModules = ['quasar', 'quasar/lang', 'lodash-es'].join('|');
|
|
|
|
|
|
|
|
/* eslint-env node */
|
2022-02-24 08:23:59 +00:00
|
|
|
module.exports = {
|
2022-03-11 10:36:40 +00:00
|
|
|
globals: {
|
|
|
|
__DEV__: true,
|
|
|
|
// TODO: Remove if resolved natively
|
|
|
|
// See https://github.com/vuejs/vue-jest/issues/175
|
|
|
|
'vue-jest': {
|
|
|
|
pug: { doctype: 'html' },
|
|
|
|
},
|
|
|
|
// Remove if using `const enums`
|
|
|
|
// See https://huafu.github.io/ts-jest/user/config/isolatedModules#example
|
|
|
|
'ts-jest': {
|
|
|
|
isolatedModules: true,
|
|
|
|
},
|
2022-02-25 12:12:14 +00:00
|
|
|
},
|
2022-03-11 10:36:40 +00:00
|
|
|
// noStackTrace: true,
|
|
|
|
// bail: true,
|
|
|
|
// cache: false,
|
|
|
|
// verbose: true,
|
|
|
|
// watch: true,
|
|
|
|
collectCoverage: false,
|
|
|
|
coverageDirectory: '<rootDir>/test/jest/coverage',
|
|
|
|
collectCoverageFrom: [
|
|
|
|
'<rootDir>/src/**/*.vue',
|
|
|
|
'<rootDir>/src/**/*.js',
|
|
|
|
'<rootDir>/src/**/*.ts',
|
|
|
|
'<rootDir>/src/**/*.jsx',
|
|
|
|
'<rootDir>/src/**/*.tsx',
|
|
|
|
],
|
|
|
|
coveragePathIgnorePatterns: ['/node_modules/', '.d.ts$'],
|
|
|
|
coverageThreshold: {
|
|
|
|
global: {
|
|
|
|
// branches: 50,
|
|
|
|
// functions: 50,
|
|
|
|
// lines: 50,
|
|
|
|
// statements: 50
|
|
|
|
},
|
2022-03-11 10:25:30 +00:00
|
|
|
},
|
2022-03-11 10:36:40 +00:00
|
|
|
testMatch: [
|
|
|
|
// Matches tests in any subfolder of 'src' or into 'test/jest/__tests__'
|
|
|
|
// Matches all files with extension 'js', 'jsx', 'ts' and 'tsx'
|
|
|
|
'<rootDir>/test/jest/__tests__/**/*.(spec|test).+(ts|js)?(x)',
|
2022-03-11 13:05:16 +00:00
|
|
|
//'<rootDir>/src/**/*.jest.(spec|test).+(ts|js)?(x)',
|
2022-03-11 10:36:40 +00:00
|
|
|
],
|
|
|
|
// Extension-less imports of components are resolved to .ts files by TS,
|
|
|
|
// grating correct type-checking in test files.
|
|
|
|
// Being 'vue' the first moduleFileExtension option, the very same imports
|
|
|
|
// will be resolved to .vue files by Jest, if both .vue and .ts files are
|
|
|
|
// in the same folder.
|
|
|
|
// This guarantee a great dev experience both for testing and type-checking.
|
|
|
|
// See https://github.com/vuejs/vue-jest/issues/188#issuecomment-620750728
|
|
|
|
moduleFileExtensions: ['vue', 'js', 'jsx', 'json', 'ts', 'tsx'],
|
|
|
|
moduleNameMapper: {
|
|
|
|
'^quasar$': 'quasar/dist/quasar.esm.prod.js',
|
|
|
|
'^~/(.*)$': '<rootDir>/$1',
|
|
|
|
'^src/(.*)$': '<rootDir>/src/$1',
|
|
|
|
'^app/(.*)$': '<rootDir>/$1',
|
|
|
|
'^components/(.*)$': '<rootDir>/src/components/$1',
|
2022-03-11 11:59:10 +00:00
|
|
|
'^composables/(.*)$': '<rootDir>/src/composables/$1',
|
2022-03-11 10:36:40 +00:00
|
|
|
'^layouts/(.*)$': '<rootDir>/src/layouts/$1',
|
|
|
|
'^pages/(.*)$': '<rootDir>/src/pages/$1',
|
|
|
|
'^assets/(.*)$': '<rootDir>/src/assets/$1',
|
|
|
|
'^boot/(.*)$': '<rootDir>/src/boot/$1',
|
|
|
|
'.*css$': '@quasar/quasar-app-extension-testing-unit-jest/stub.css',
|
2022-03-11 10:25:30 +00:00
|
|
|
},
|
2022-03-11 10:36:40 +00:00
|
|
|
transform: {
|
|
|
|
// See https://jestjs.io/docs/en/configuration.html#transformignorepatterns-array-string
|
|
|
|
[`^(${esModules}).+\\.js$`]: 'babel-jest',
|
|
|
|
'^.+\\.(ts|js|html)$': 'ts-jest',
|
|
|
|
// vue-jest uses find-babel-file, which searches by this order:
|
|
|
|
// (async) .babelrc, .babelrc.js, package.json, babel.config.js
|
|
|
|
// (sync) .babelrc, .babelrc.js, babel.config.js, package.json
|
|
|
|
// https://github.com/tleunen/find-babel-config/issues/33
|
|
|
|
'.*\\.vue$': 'vue-jest',
|
2022-03-14 10:31:37 +00:00
|
|
|
'.+\\.(css|styl|less|sass|scss|svg|png|jpg|ttf|woff|woff2)$': 'jest-transform-stub',
|
2022-03-11 10:36:40 +00:00
|
|
|
},
|
|
|
|
transformIgnorePatterns: [`node_modules/(?!(${esModules}))`],
|
|
|
|
snapshotSerializers: ['<rootDir>/node_modules/jest-serializer-vue'],
|
2022-02-24 08:23:59 +00:00
|
|
|
};
|