【发布时间】:2021-01-13 17:09:17
【问题描述】:
我正在使用 jest 进行集成测试,其中一个文件夹下有 20 个测试文件。我需要确保在运行测试时不需要执行该文件夹中的三个文件。我尝试使用 testPathIgnorePatterns 但它仅适用于文件夹而不适用于文件。该怎么做?
jest.config.js
/**
* @file Jest Integration Test Configuration File
*/
module.exports = {
roots: ['../../tests'],
testRegex: '_*_integration.test.(js|ts|tsx)?$',
globals: {
'ts-jest': {
tsconfig: 'tsconfig.json',
},
},
moduleFileExtensions: ['ts', 'js'],
transform: {
'^.+\\.(ts|tsx)$': 'ts-jest',
},
testPathIgnorePatterns: ['tests/api/modules/m3/sample.test.ts'],
testEnvironment: 'node',
reporters: [
'default',
[
'../../node_modules/jest-html-reporter',
{
pageTitle: 'Integration Test Report',
outputPath: 'tests/reports/integration-test-report.html',
includeFailureMsg: true,
},
],
],
};
【问题讨论】:
-
为什么不更改文件名,或者将其移动到 lm 例如示例目录并忽略它?
-
不,这是不可能的。遵循项目的一些标准。所以不建议移动到文件夹@jonrsharpe
-
什么标准?并且不推荐!== 不可能,拥有一个看似是测试文件但不是的文件真的明智吗(它是什么)?这显然会混淆测试发现,但更重要的是可能会混淆 人们。
-
@muthu 如何将文件重命名为
_integration.test.skip.js -
这是一个答案?你告诉我你不能重命名文件。
标签: javascript node.js jestjs jasmine