jest.config.js 1.9 KB

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