This repository has been archived on 2025-09-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
nezha-nezha-fronted/nezha-fronted/test/unit/jest.conf.js
2022-04-15 13:42:54 +08:00

41 lines
1.4 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

const path = require('path')
module.exports = {
verbose: true,
// testURL: 'http://localhost/',
rootDir: path.resolve(__dirname, '../../'),
transform: {
'^.+\\.js$': '<rootDir>/node_modules/babel-jest',
'.*\\.(vue)$': '<rootDir>/node_modules/vue-jest'
},
// moduleFileExtensions: [
// 'js',
// 'json',
// 'vue'
// ],
moduleNameMapper: {
'^@\/(.*?\.?(js|vue)?|)$': '<rootDir>/src/$1', // @路径转换,例如:@/components/Main.vue -> rootDir/src/components/Main.vue
'\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': '<rootDir>/test/unit/__mocks__/fileMock.js', // 模拟加载静态文件
'\\.(css|less|scss|sass)$': '<rootDir>/test/unit/__mocks__/styleMock.js'  // 模拟加载样式文件
},
testMatch: [ // 匹配测试用例的文件
'<rootDir>/test/unit/specs/*.spec.js'
],
moduleDirectories: [
'node_modules'
],
// testPathIgnorePatterns: [
// '<rootDir>/test/e2e'
// ],
// setupFiles: ['<rootDir>/test/unit/setup'],
// snapshotSerializers: ['<rootDir>/node_modules/jest-serializer-vue'],
coverageDirectory: '<rootDir>/test/unit/coverage', // 覆盖率报告的目录
collectCoverageFrom: [ // 测试报告想要覆盖那些文件,目录,前面加!是避开这些文件
// 'test/unit/specs/*.(js)',
'src/components/common/js/tool.js'
// '!src/main.js',
// '!src/router/index.js',
// '!**/node_modules/**'
]
}