jest.config.js 916 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. module.exports = {
  2. // 单元测试
  3. moduleFileExtensions: [
  4. 'js',
  5. 'jsx',
  6. 'json',
  7. 'vue',
  8. 'ts',
  9. 'tsx'
  10. ],
  11. transform: {
  12. '^.+\\.vue$': 'vue-jest',
  13. '.+\\.(css|styl|less|sass|scss|svg|png|jpg|ttf|woff|woff2)$': 'jest-transform-stub',
  14. '^.+\\.jsx?$': 'babel-jest',
  15. '^.+\\.tsx?$': 'ts-jest'
  16. },
  17. moduleNameMapper: {
  18. '^@/(.*)$': '<rootDir>/src/$1'
  19. },
  20. snapshotSerializers: ['jest-serializer-vue'],
  21. testMatch: [
  22. '**/tests/unit/**/*.spec.(js|jsx|tsx)|**/__tests__/*.(js|jsx|tsx)'
  23. ],
  24. collectCoverageFrom: ['src/utils/**/*.{js,vue}', '!src/utils/auth.js', '!src/utils/request.js', 'src/components/**/*.{js,vue}'],
  25. coverageDirectory: '<rootDir>/tests/unit/coverage',
  26. // 'collectCoverage': true,
  27. 'coverageReporters': [
  28. 'lcov',
  29. 'text-summary'
  30. ],
  31. testURL: 'http://localhost/',
  32. globals: {
  33. 'ts-jest': {
  34. babelConfig: true
  35. }
  36. }
  37. }