Do you want to request a feature or report a bug?
Bug
What is the current behavior?
When adding a folder to testPathIgnorePatterns then jest will ignore tests in those files, but it will complain about any obsolete snapshots in those folders.
If the current behavior is a bug, please provide the steps to reproduce and either a repl.it demo through https://repl.it/languages/jest or a minimal repository on GitHub that we can yarn install and yarn test.
testPathIgnorePatternsyarn testA minimal repository can be found here. Running yarn test ignores the test in ignored/, but still complains about the snapshot file in that directory.
What is the expected behavior?
I expect jest to ignore snapshots in ignored folders.
Please provide your exact Jest configuration and mention your Jest, node, yarn/npm version and operating system.
Jest config:
{
"testPathIgnorePatterns" : [
"<rootDir>/ignored/"
]
}
Jest version: 20.0.4
Node version: 8.1.2
yarn version: 0.27.5
OS: Linux (Fedora 24)
Also since the new behavior is to fail on obsolete snapshot files, it is quite frustrating as there is nothing we can do about it!
In my case I'm using react-styleguidist with the snapguidist plugin that does output coverage files in a .snapguidist subfolder.
@TiddoLangerak I ran into this same issue, and I used the roots configuration in addition to the testPathIgnorePatterns. This lets you limit where jest looks for test files. I tested it against your repo and it solved the issue
"jest" : {
"roots": [
"<rootDir>/included/"
],
"testPathIgnorePatterns" : [
"<rootDir>/ignored/"
]
}
Most helpful comment
@TiddoLangerak I ran into this same issue, and I used the roots configuration in addition to the
testPathIgnorePatterns. This lets you limit where jest looks for test files. I tested it against your repo and it solved the issue