module.exports = { transform: { // 使用工具让js能读懂的转换器 '^.+\\.tsx?$': 'ts-jest' }, // 配置测试代码的覆盖率 collectCoverage: true, collectCoverageFrom: ["packages/**/*vue", "!**/node_modules/**"], testMatch: ['<rootDir>/test/**/+(*.)+(spec.ts?(x))'],// 运行jest时匹配的文件 coverageDirectory: '<rootDir>/test-results/', // 检测覆盖文件夹 testPathIgnorePatterns: ['<rootDir>/node_modules/'], // 检测忽略文件夹 moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'], // 模块使用的文件扩展名数组,越左越快匹配 globals: { // 一组全局变量,在所有测试环境下都可以访问。 'ts-jest': { tsConfigFile: './tsconfig.test.json' } }, moduleNameMapper: {// 从正则表达式到模块名的映射,允许将资源(如图像或样式)存到单个模块。 '\\.(less)$': 'identity-obj-proxy' }, setupFiles: ['<rootDir>/test/enzyme-setup.ts']// 运行一些代码以配置或设置测试环境的模块的路径列表。每个setupFile将在每个测试文件中运行一次。};
参考:https://www.jianshu.com/p/2f00475ade2a