jest ignore All In one
jest ignore All In one
modulePathIgnorePatterns
https://jestjs.io/docs/en/configuration
modulePathIgnorePatterns [array]
https://jestjs.io/docs/en/configuration#modulepathignorepatterns-arraystring
// Default
[]
// Example
["<rootDir>/build/"]
testPathIgnorePatterns [array]
https://jestjs.io/docs/en/configuration#testpathignorepatterns-arraystring
// Default
["/node_modules/"]
// Example
["<rootDir>/build/", "<rootDir>/node_modules/"].
coveragePathIgnorePatterns [array]
https://jestjs.io/docs/en/configuration#coveragepathignorepatterns-arraystring
// Default
["/node_modules/"]
// Example
["<rootDir>/build/", "<rootDir>/node_modules/"].
watchPathIgnorePatterns [array]
https://jestjs.io/docs/en/configuration#watchpathignorepatterns-arraystring
// Example
["<rootDir>/node_modules/"].
transformIgnorePatterns [array]
https://jestjs.io/docs/en/configuration#transformignorepatterns-arraystring
// Default
["/node_modules/", "\\.pnp\\.[^\\\/]+$"]
// Example
["<rootDir>/bower_components/", "<rootDir>/node_modules/"].
https://jestjs.io/docs/en/tutorial-react-native#transformignorepatterns-customization
demos
modulePathIgnorePatterns: ["directoryNameToIgnore"]
# OR
modulePathIgnorePatterns: ["<rootDir>/dist/"]
jest.config.js
// jest.config.js
const {defaults} = require('jest-config');
module.exports = {
// ...
moduleFileExtensions: [
...defaults.moduleFileExtensions,
'js',
'mjs',
// 'jsx',
// 'ts',
// 'tsx',
],
// ...
// preset: [],
modulePathIgnorePatterns: [
"<rootDir>/dist/",
"<rootDir>/000-xyz/",
"<rootDir>/jest/",
"<rootDir>/node.js-week-one/",
"<rootDir>/practices/",
],
watchPathIgnorePatterns: [
"<rootDir>/dist/",
"<rootDir>/000-xyz/",
"<rootDir>/jest/",
"<rootDir>/node.js-week-one/",
"<rootDir>/practices/",
],
testPathIgnorePatterns: [
"<rootDir>/build/",
"<rootDir>/node_modules/",
],
coveragePathIgnorePatterns: [
"<rootDir>/build/",
"<rootDir>/node_modules/",
],
};
exclude/ignore file(s) from coverage
{
"jest": {
"collectCoverageFrom": [
"src/**/{!(ignore-me),}.js"
]
}
}
/* istanbul ignore file */
/* istanbul ignore next */
function myFunc() {
console.log(
"Not covered but won't appear on coverage reports as such"
);
}
refs
https://www.cnblogs.com/xgqfrms/tag/jest/
https://stackoverflow.com/questions/40486567/how-to-exclude-files-from-jest-watch
https://codewithhugo.com/jest-exclude-coverage/
https://codewithhugo.com/run-skip-single-jest-test/
https://github.com/facebook/jest/issues/1815
©xgqfrms 2012-2020
www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!
原创文章,版权所有©️xgqfrms, 禁止转载 🈲️,侵权必究⚠️!
本文首发于博客园,作者:xgqfrms,原文链接:https://www.cnblogs.com/xgqfrms/p/13598791.html
未经授权禁止转载,违者必究!