jest.config,js:
module.exports = {
preset: 'jest-preset-angular',
setupFilesAfterEnv: ['<rootDir>/tests/client/jest-setup.ts'],
verbose: true,
testPathIgnorePatterns: [
'<rootDir>/cypress/',
'<rootDir>/_build/',
'<rootDir>/_build_production/',
'<rootDir>/client/environments/'
],
globals: {
'ts-jest': {
tsConfig: '<rootDir>/tsconfig.test.json',
stringifyContentPathRegex: '\\.html$',
astTransformers: [require.resolve('jest-preset-angular/InlineHtmlStripStylesTransformer')]
}
},
transform: {
'^.+\\.(ts|js|html)$': 'ts-jest'
},
reporters: ['default', ['jest-junit', { outputDirectory: './_results/unit/', outputName: './test-results.xml' }]],
collectCoverage: true,
coverageReporters: ['text', 'html'],
coverageDirectory: './_coverage/unit/'
};
命令:
jest --config ./jest.config.js --testPathIgnorePatterns ['<rootDir>/tests/server/contract']",
错误:
> npx cross-env MOP_NODE_ENV=test jest --config ./jest.config.js --testPathIgnorePatterns ['<rootDir>/tests/server/contract']
No tests found, exiting with code 1
Run with `--passWithNoTests` to exit with code 0
In /home/karl/dev/MOP
133 files checked.
testMatch: **/__tests__/**/*.[jt]s?(x), **/?(*.)+(spec|test).[tj]s?(x) - 18 matches
testPathIgnorePatterns: [/home/karl/dev/MOP/tests/server/contract] - 0 matches
testRegex: - 0 matches
Pattern: - 0 matches
现在,我在测试/服务器/合同中有测试文件。如果我省略--testPathIgnorePatterns ['<rootDir>/tests/server/contract']
,它将运行该目录中的文件。