You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Oct 16, 2025. It is now read-only.
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/yarn cache on our CI server.
Change jest's rootDir from thinkCERCA/ to thinkCERCA/client
Since create-react-app limits our ability to customize our configuration, solution 2 required a little bit of hackery that's worth sharing.
Hello 👋
At ThinkCERCA we're experiencing an issue with
jest's config. Jest has a optimization tool calledjest-haste-mapwhich appears to walk the entirerootDirlooking for javascript code. This includesnode_modulesfrom old frontend code in a different directory, it includes javascript included with ruby in ourvendordirectory. And on our CI server, it includes everything cached by npm & yarn inthinkCERCA/.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/clientSince 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.jsand@zeal/react-scripts/scripts/utils/createJestConfig.jsto our codebase and made some changes to move jest'srootDir. I posted a diff of the changes here: https://gist.github.com/bionikspoon/af66c22122dc19f57ebf0e04b0137935About 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.