-
Notifications
You must be signed in to change notification settings - Fork 46.9k
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
[WIP] Run Jest in PROD mode too #10273
Conversation
cc @aaronabramov Have you seen those issues in last two screenshots? It seems like multi project runner can't find mocks in some cases. |
@gaearon i have seen it in www actually. But they were only in 2 or 3 tests, so i just fixed them by using mock/unmock and didn't look into it. Are those the only two modules that can't be found in React or is there more? |
@@ -0,0 +1,18 @@ | |||
/* eslint-disable */ | |||
global.__DEV__ = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need to set NODE_ENV to 'production' too for fbjs to work? (caution that in the past this made the transforms fail for me because the transforms read NODE_ENV and expect it to be 'test'. might need to set it to 'test' and back before/after the babel transform in the jest preprocessor.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
caution that in the past this made the transforms fail for me because the transforms read NODE_ENV and expect it to be 'test'. might need to set it to 'test' and back before/after the babel transform in the jest preprocessor.
That's what I ran into. I suppose yes, we'll need that.
I used to have more of these when I tried at first. I was sharing all JS setup files between projects, and only had an additional |
Related to Jest error: we might need to add |
This is a rough proof of concept. It adds production mode runner project to our Jest setup.
Example running a test in Stack, Fiber DEV and Fiber PROD:
Not all unit tests are friendly to this. And it doesn't completely represent the PROD mode because I haven't applied PROD transforms. For example it doesn't strip
warning
calls leading to:On the other hand, applying all PROD transforms would also be a bit tricky because we often assert on error message name which would be stripped. Maybe we can have
toThrowReactError
matcher that just expectsMinified exception
in PROD.Some are explicitly DEV only tests:
We should probably gate them.
This is also surfacing what appears to be Jest multi project runner bugs. For example, it appears that some mocks get broken in multi project setup:
Overall I think this is a promising direction but we'll need Jest MPR to become more stable to continue.