I'm trying to ignore a specific folder in the testMatch pattern of Jest.
I have my tests in a __tests__ folder and I want to be able to have a folder __config__ into it with all files inside which should be ignored.
/__tests__
/__config__
someConfig.jsx
/MyComponent.jsx
/MyComponent.jsx
My tests in the __tests__ folder will import the files from the __config__ folder so I don't want to ignore them with the transformIgnorePatterns.
But if I don't ignore the folder, Jest tries to run in the folder and returns an error:
FAIL
src/components/__tests__/__config__/someConfig.jsxYour test suite must contain at least one test.
I've tried a few different patterns but I can't find a way to ignore the __config__ folder
testMatch: [
"**/__tests__/!(__config__)/**/*.(js)?(x)", // Doesn't work
"**/__tests__/(**|!__config__)/*.(js)?(x)", // Doesn't work
"**/__tests__/(**|?!__config__)/*.(js)?(x)", // Doesn't work
"**/__tests__/{**,!__config__}/*.(js)?(x)", // Doesn't work
],
Any idea how I can ignore the sub-folder like this?
Try to use testPathIgnorePatterns, instead.
If the test path matches any of the patterns, it will be skipped.
Use the string token to include the path to your project's root.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With