Skip to content
代码片段 群组 项目
jest.config.js 2.3 KB
更新 更旧
  • 了解如何忽略特定修订
  • module.exports = {
      globals: {
    
    Timotej Ecimovic's avatar
    Timotej Ecimovic 已提交
        __DEV__: true,
    
      },
      globalSetup: '<rootDir>/test/global-setup.js',
      globalTeardown: '<rootDir>/test/global-teardown.js',
    
    Timotej Ecimovic's avatar
    Timotej Ecimovic 已提交
      setupFilesAfterEnv: ['<rootDir>/test/jest/jest.setup.js'],
    
      // noStackTrace: true,
      // bail: true,
      // cache: false,
      // verbose: true,
      // watch: true,
      collectCoverage: true,
      coverageDirectory: '<rootDir>/test/jest/coverage',
      collectCoverageFrom: [
    
    Timotej Ecimovic's avatar
    Timotej Ecimovic 已提交
        '<rootDir>/src-electron/**/*.js',
    
        '<rootDir>/src-shared/**/*.js',
    
    Timotej Ecimovic's avatar
    Timotej Ecimovic 已提交
        // Enable these once the UI testing is available
    
        '<rootDir>/src/**/*.vue',
        '<rootDir>/src/**/*.js',
        '<rootDir>/src/**/*.jsx',
    
      ],
      coverageThreshold: {
        global: {
    
    Timotej Ecimovic's avatar
    Timotej Ecimovic 已提交
          // Note to whoever is looking at these number:
          // We need to settle on much higher number, so we will slowly
          // be inching this upward, as we add more unit tests.
          // DO NOT EVER DECREASE THESE NUMBERS, PLEASE, UNLESS FOR A GOOD REASON.
    
          statements: 67,
          branches: 54,
    
    Timotej Ecimovic's avatar
    Timotej Ecimovic 已提交
        },
    
    Timotej Ecimovic's avatar
    Timotej Ecimovic 已提交
      testMatch: ['<rootDir>/test/*.test.js'],
      moduleFileExtensions: ['vue', 'js', 'jsx', 'json', 'ts', 'tsx'],
    
      moduleNameMapper: {
        '^vue$': '<rootDir>/node_modules/vue/dist/vue.common.js',
    
    Timotej Ecimovic's avatar
    Timotej Ecimovic 已提交
        '^test-utils$':
          '<rootDir>/node_modules/@vue/test-utils/dist/vue-test-utils.js',
    
        '^quasar$': '<rootDir>/node_modules/quasar/dist/quasar.common.js',
        '^~/(.*)$': '<rootDir>/$1',
        '^src/(.*)$': '<rootDir>/src/$1',
        '.*css$': '<rootDir>/test/jest/utils/stub.css',
        '.*\\.sql$': '<rootDir>/test/jest/__mocks__/zap-sql-mock.js',
    
    Timotej Ecimovic's avatar
    Timotej Ecimovic 已提交
        '\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$':
          '<rootDir>/test/jest/__mocks__/file-mock.js',
    
      },
      transform: {
        '.*\\.vue$': 'vue-jest',
    
        '.*\\.[jt]sx?$': 'babel-jest',
    
    Timotej Ecimovic's avatar
    Timotej Ecimovic 已提交
        '.+\\.(css|styl|less|sass|scss|svg|png|jpg|ttf|woff|woff2)$':
          'jest-transform-stub',
    
        // use these if NPM is being flaky
        // '.*\\.vue$': '<rootDir>/node_modules/@quasar/quasar-app-extension-testing-unit-jest/node_modules/vue-jest',
        // '.*\\.js$': '<rootDir>/node_modules/@quasar/quasar-app-extension-testing-unit-jest/node_modules/babel-jest'
      },
    
    Timotej Ecimovic's avatar
    Timotej Ecimovic 已提交
      transformIgnorePatterns: ['<rootDir>/node_modules/(?!quasar/lang)'],
      snapshotSerializers: ['<rootDir>/node_modules/jest-serializer-vue'],
    
      testResultsProcessor: 'jest-sonar-reporter',