如何在玩笑中跳过文件执行?

mut*_*thu 4 javascript node.js jasmine jestjs

我正在使用 jest 进行集成测试,其中一个文件夹下有 20 个测试文件。我需要确保在运行测试时不需要执行该文件夹中的三个文件。我尝试使用testPathIgnorePatterns但它仅适用于文件夹而不适用于文件。怎么做?

笑话配置.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,
      },
    ],
  ],
};

Run Code Online (Sandbox Code Playgroud)

Won*_*Seo 6

--testPathIgnorePatterns使用cli 选项怎么样?

yarn test --testPathIgnorePatterns=user.test.ts

如果对于多个文件,可以使用下面的。

yarn test --testPathIgnorePatterns=filename1 filename2