jest.config.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. 'ts-jest': {
  18. tsconfig: {
  19. target: 'esnext',
  20. sourceMap: true
  21. }
  22. }
  23. },
  24. coverageDirectory: 'coverage',
  25. coverageReporters: ['html', 'lcov', 'text'],
  26. collectCoverageFrom: [
  27. 'packages/*/src/**/*.ts',
  28. '!packages/runtime-test/src/utils/**',
  29. '!packages/template-explorer/**',
  30. '!packages/sfc-playground/**',
  31. '!packages/size-check/**',
  32. '!packages/runtime-core/src/profiling.ts',
  33. '!packages/runtime-core/src/customFormatter.ts',
  34. // DOM transitions are tested via e2e so no coverage is collected
  35. '!packages/runtime-dom/src/components/Transition*',
  36. // only called in browsers
  37. '!packages/vue/src/devCheck.ts',
  38. // only used as a build entry
  39. '!packages/vue/src/runtime.ts',
  40. // mostly just entries
  41. '!packages/vue-compat/**'
  42. ],
  43. watchPathIgnorePatterns: ['/node_modules/', '/dist/', '/.git/'],
  44. moduleFileExtensions: ['ts', 'tsx', 'js', 'json'],
  45. moduleNameMapper: {
  46. '@vue/compat': '<rootDir>/packages/vue-compat/src',
  47. '^@vue/(.*?)$': '<rootDir>/packages/$1/src',
  48. vue: '<rootDir>/packages/vue/src'
  49. },
  50. rootDir: __dirname,
  51. testMatch: ['<rootDir>/packages/**/__tests__/**/*spec.[jt]s?(x)'],
  52. testPathIgnorePatterns: process.env.SKIP_E2E
  53. ? // ignore example tests on netlify builds since they don't contribute
  54. // to coverage and can cause netlify builds to fail
  55. ['/node_modules/', '/examples/__tests__']
  56. : ['/node_modules/']
  57. }