Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/34.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何在jest中跳过执行文件?_Javascript_Node.js_Jestjs_Jasmine - Fatal编程技术网

Javascript 如何在jest中跳过执行文件?

Javascript 如何在jest中跳过执行文件?,javascript,node.js,jestjs,jasmine,Javascript,Node.js,Jestjs,Jasmine,我正在与jest一起进行集成测试,其中一个文件夹下有20个测试文件。我需要确保在运行测试时不需要执行该文件夹中的三个文件。我尝试了testPathIgnorePatterns,但它只适用于文件夹,不适用于文件。怎么做 jest.config.js /** * @file Jest Integration Test Configuration File */ module.exports = { roots: ['../../tests'], testRegex: '_*_integ

我正在与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,
      },
    ],
  ],
};

使用
--testPathIgnorePatterns
cli选项怎么样

纱线测试--testPathIgnorePatterns=user.test.ts

如果是多个文件,可以使用下面的


纱线测试--testPathIgnorePatterns=filename1 filename2
您可以像这样使用Zest json的
collectCoverage from
参数

collectCoverageFrom: ['path-to-file1','path-to-file2'],
注意:此选项要求collectCoverage设置为true或Jest,以便使用
--覆盖率调用。

提及


在文档中,他们指定了一种模式,但它也适用于文件静态文件路径。

为什么不更改文件名,或将其移动到lm(例如samples)目录中并忽略它?不,这是不可能的。在项目中遵循一些标准。所以不建议移动到文件夹@jonrsharpeWhat standards?而且不推荐!==不可能,有一个似乎是测试文件但不是(它是什么)的文件真的明智吗?这显然会混淆测试发现,但更重要的是可能会混淆人们。@muthu将文件重命名为
\u integration.test.skip.js如何?答案是这样的?您告诉我无法重命名该文件。他们已经在使用testPathIgnorePatterns,并报告它与目录而不是文件匹配;为什么CLI文件和配置文件会有所不同?