-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
jest rootDir #23
Comments
@bionikspoon Thanks for reporting this. It's an interesting problem, for sure. TLDR: It might be worth opening this issue upstream on facebook/create-react-app. They may not want to fix it there, but either way, there's some work being done upstream that's going to have an impact on a solution for this problem, so we're going to wait until that work is available to us to see if that resolves the issue. We'll keep this issue open to remind ourselves to come back and check once we move to CRA 2.0. Longer version: It seems like this is an issue with the upstream CRA itself. I suspect that if you used the original create-react-app in your repo, it would have the same problems as this fork. I think it would be worth opening an issue on that repository to see what they say about it. However, I think that CRA expects to own the entire repository where the app is generated, so they may deem this as something they don't want to fix. I might be wrong about that, but I think that would be a reasonable response on their part. Since this fork is intended to be embedded within a parent app, it may fall to us to address this issue. The diff you provided seems reasonable in that light, with one minor concern: What information does jest/jest-haste-map get from having the base project directory as its In digging into this problem, I noticed that there's a bunch of work being done upstream to support lerna/yarn workspaces, and that work will have an impact on what our solution might look like. That work might even fix this issue as a side-effect. See facebook#3741 for example. Because of that, we're going to hold off on addressing the issue here for now. We'll keep this issue open and revisit after we can upgrade to CRA 2.0. |
@randycoulman Thank you for digging into this, very much appreciate the insights. As @bionikspoon mentioned the issues related to this are preventing snapshot testing 📸in our app. To that end our solution in the interim is going to be to pull these test scripts in locally to our project as seen in the diff provided. Again, super appreciative of the time spent looking at this. We'll keep on eye for CRA 2.0 as I'm sure you all will as well. |
I second everything @bmatto said. Thank you @randycoulman for looking into this so quickly and thoroughly. It is appreciated! 😄 |
Hello 👋
At ThinkCERCA we're experiencing an issue with
jest
's config. Jest has a optimization tool calledjest-haste-map
which appears to walk the entirerootDir
looking for javascript code. This includesnode_modules
from old frontend code in a different directory, it includes javascript included with ruby in ourvendor
directory. 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
/yarn
cache on our CI server.Change jest's
rootDir
fromthinkCERCA/
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'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.
The text was updated successfully, but these errors were encountered: