|
| 1 | +const esModules = ['quasar/lang', 'lodash-es'].join('|') |
| 2 | + |
| 3 | +/* eslint-env node */ |
| 4 | +module.exports = { |
| 5 | + globals: { |
| 6 | + __DEV__: true, |
| 7 | + // TODO: Remove if resolved natively |
| 8 | + // See https://github.com/vuejs/vue-jest/issues/175 |
| 9 | + 'vue-jest': { |
| 10 | + pug: { doctype: 'html' } |
| 11 | + } |
| 12 | + }, |
| 13 | + // noStackTrace: true, |
| 14 | + // bail: true, |
| 15 | + // cache: false, |
| 16 | + // verbose: true, |
| 17 | + // watch: true, |
| 18 | + collectCoverage: false, |
| 19 | + coverageDirectory: '<rootDir>/test/jest/coverage', |
| 20 | + collectCoverageFrom: [ |
| 21 | + '<rootDir>/src/**/*.vue', |
| 22 | + '<rootDir>/src/**/*.js', |
| 23 | + '<rootDir>/src/**/*.ts', |
| 24 | + '<rootDir>/src/**/*.jsx', |
| 25 | + '<rootDir>/src/**/*.tsx' |
| 26 | + ], |
| 27 | + coveragePathIgnorePatterns: ['/node_modules/', '.d.ts$'], |
| 28 | + coverageThreshold: { |
| 29 | + global: { |
| 30 | + // branches: 50, |
| 31 | + // functions: 50, |
| 32 | + // lines: 50, |
| 33 | + // statements: 50 |
| 34 | + } |
| 35 | + }, |
| 36 | + testMatch: [ |
| 37 | + // Matches tests in any subfolder of 'src' or into 'test/jest/__tests__' |
| 38 | + // Matches all files with extension 'js', 'jsx', 'ts' and 'tsx' |
| 39 | + '<rootDir>/test/jest/__tests__/**/*.(spec|test).+(ts|js)?(x)', |
| 40 | + '<rootDir>/src/**/*.jest.(spec|test).+(ts|js)?(x)' |
| 41 | + ], |
| 42 | + // Extension-less imports of components are resolved to .ts files by TS, |
| 43 | + // grating correct type-checking in test files. |
| 44 | + // Being 'vue' the first moduleFileExtension option, the very same imports |
| 45 | + // will be resolved to .vue files by Jest, if both .vue and .ts files are |
| 46 | + // in the same folder. |
| 47 | + // This guarantee a great dev experience both for testing and type-checking. |
| 48 | + // See https://github.com/vuejs/vue-jest/issues/188#issuecomment-620750728 |
| 49 | + moduleFileExtensions: ['vue', 'js', 'jsx', 'json', 'ts', 'tsx'], |
| 50 | + moduleNameMapper: { |
| 51 | + '^~/(.*)$': '<rootDir>/$1', |
| 52 | + '^src/(.*)$': '<rootDir>/src/$1', |
| 53 | + '^app/(.*)$': '<rootDir>/$1', |
| 54 | + '^components/(.*)$': '<rootDir>/src/components/$1', |
| 55 | + '^layouts/(.*)$': '<rootDir>/src/layouts/$1', |
| 56 | + '^pages/(.*)$': '<rootDir>/src/pages/$1', |
| 57 | + '^assets/(.*)$': '<rootDir>/src/assets/$1', |
| 58 | + '^boot/(.*)$': '<rootDir>/src/boot/$1', |
| 59 | + '.*css$': '@quasar/quasar-app-extension-testing-unit-jest/stub.css' |
| 60 | + }, |
| 61 | + transform: { |
| 62 | + // See https://jestjs.io/docs/en/configuration.html#transformignorepatterns-array-string |
| 63 | + [`^(${esModules}).+\\.js$`]: 'babel-jest', |
| 64 | + '^.+\\.(ts|js|html)$': 'ts-jest', |
| 65 | + // vue-jest uses find-babel-file, which searches by this order: |
| 66 | + // (async) .babelrc, .babelrc.js, package.json, babel.config.js |
| 67 | + // (sync) .babelrc, .babelrc.js, babel.config.js, package.json |
| 68 | + // https://github.com/tleunen/find-babel-config/issues/33 |
| 69 | + '.*\\.vue$': 'vue-jest', |
| 70 | + '.+\\.(css|styl|less|sass|scss|svg|png|jpg|ttf|woff|woff2)$': |
| 71 | + 'jest-transform-stub' |
| 72 | + }, |
| 73 | + transformIgnorePatterns: [`node_modules/(?!(${esModules}))`], |
| 74 | + snapshotSerializers: ['<rootDir>/node_modules/jest-serializer-vue'] |
| 75 | +} |
0 commit comments