jest.config.js 1.8 KB

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