jest.config.js 863 B

12345678910111213141516171819202122232425
  1. module.exports = {
  2. moduleFileExtensions: ['vue', 'js', 'ts', 'tsx'],
  3. preset: 'ts-jest',
  4. testEnvironment: 'jsdom',
  5. transform: {
  6. '^.+\\.vue$': 'vue-jest', // vue 文件用 vue-jest 转换
  7. '^.+\\.ts$': 'ts-jest' // ts 文件用 ts-jest 转换
  8. },
  9. // 匹配 __tests__ 目录下的 .js/.ts 文件 或其他目录下的 xx.test.js/ts xx.spec.js/ts
  10. testRegex: '(/__tests__/*|(\\.|/)(test|spec))\\.(ts|tsx)$',
  11. //testRegex: '__tests__.action.spec.ts',
  12. // 支持源代码中相同的 `@` -> `src` 别名
  13. moduleNameMapper: {
  14. '^@/(.*)$': '<rootDir>/src/$1'
  15. },
  16. // 是否开启将测试覆盖率信息输出为报告
  17. collectCoverage: true,
  18. // 报告应从那些文件中收集
  19. collectCoverageFrom: [
  20. 'src/packages/__VUE/**/*.{js,jsx,ts,tsx,vue}',
  21. '!**/node_modules/**',
  22. '!**/demo.vue/**',
  23. '!**/index.taro.vue/**'
  24. ]
  25. };