-
Notifications
You must be signed in to change notification settings - Fork 2
jest rootDir #23
Description
Hello 👋
At ThinkCERCA we're experiencing an issue with jest's config. Jest has a optimization tool called jest-haste-map which appears to walk the entire rootDir looking for javascript code. This includes node_modules from old frontend code in a different directory, it includes javascript included with ruby in our vendor directory. And on our CI server, it includes everything cached by npm & yarn in thinkCERCA/.semaphore-cache. As you might imagine, there's all sorts of clashes happening. For whatever reason, certain snapshot tests reliably fail on our CI server.
I found 2 solutions:
-
Delete
npm/yarncache on our CI server. -
Change jest's
rootDirfromthinkCERCA/tothinkCERCA/client
Since create-react-app limits our ability to customize our configuration, solution 2 required a little bit of hackery that's worth sharing.
I copied in @zeal/react-scripts/scripts/test.js and @zeal/react-scripts/scripts/utils/createJestConfig.js to our codebase and made some changes to move jest's rootDir. I posted a diff of the changes here: https://gist.github.com/bionikspoon/af66c22122dc19f57ebf0e04b0137935
About half the changes are a product of copying the file over to our local project directory, the other half are for moving jest's rootDir.
These changes may or may not belong in your repo, you decide. If they are, happy to help any way I can.