jest.config.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. module.exports = {
  2. preset: 'ts-jest',
  3. setupFilesAfterEnv: ['./scripts/setupJestEnv.ts'],
  4. globals: {
  5. __DEV__: true,
  6. __TEST__: true,
  7. __VERSION__: require('./package.json').version,
  8. __BROWSER__: false,
  9. __GLOBAL__: false,
  10. __ESM_BUNDLER__: true,
  11. __ESM_BROWSER__: false,
  12. __NODE_JS__: true,
  13. __FEATURE_OPTIONS_API__: true,
  14. __FEATURE_SUSPENSE__: true,
  15. __FEATURE_PROD_DEVTOOLS__: false,
  16. __COMPAT__: true
  17. },
  18. coverageDirectory: 'coverage',
  19. coverageReporters: ['html', 'lcov', 'text'],
  20. collectCoverageFrom: [
  21. 'packages/*/src/**/*.ts',
  22. '!packages/runtime-test/src/utils/**',
  23. '!packages/template-explorer/**',
  24. '!packages/sfc-playground/**',
  25. '!packages/size-check/**',
  26. '!packages/runtime-core/src/profiling.ts',
  27. '!packages/runtime-core/src/customFormatter.ts',
  28. // DOM transitions are tested via e2e so no coverage is collected
  29. '!packages/runtime-dom/src/components/Transition*',
  30. // only called in browsers
  31. '!packages/vue/src/devCheck.ts',
  32. // only used as a build entry
  33. '!packages/vue/src/runtime.ts',
  34. // mostly just entries
  35. '!packages/vue-compat/**'
  36. ],
  37. watchPathIgnorePatterns: ['/node_modules/', '/dist/', '/.git/'],
  38. moduleFileExtensions: ['ts', 'tsx', 'js', 'json'],
  39. moduleNameMapper: {
  40. '@vue/compat': '<rootDir>/packages/vue-compat/src',
  41. '^@vue/(.*?)$': '<rootDir>/packages/$1/src',
  42. vue: '<rootDir>/packages/vue/src'
  43. },
  44. rootDir: __dirname,
  45. testMatch: ['<rootDir>/packages/**/__tests__/**/*spec.[jt]s?(x)'],
  46. testPathIgnorePatterns: process.env.SKIP_E2E
  47. ? // ignore example tests on netlify builds since they don't contribute
  48. // to coverage and can cause netlify builds to fail
  49. ['/node_modules/', '/examples/__tests__']
  50. : ['/node_modules/']
  51. }