Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upFix jest-preset to use internal preprocessor (fix testing with 0.56) #20068
Conversation
facebook-github-bot
added
the
CLA Signed
label
Jul 6, 2018
This comment has been minimized.
This comment has been minimized.
I think that failed end_to_end tests does not have any relation to this change... As I know, jest tests in generated application from template currently does not exists. See this comment: #19859 (comment) from @hramos and test plan above it. |
This comment has been minimized.
This comment has been minimized.
Hey thanks for the PR! Yes it looks like all those tests are failing because of the packager not starting (?). I'll let the core know, hopefully we can get this passing tests -> reviewed -> merged in master -> cherry picked for 0.56.1 |
This comment has been minimized.
This comment has been minimized.
stevehollaar
commented
Jul 6, 2018
@vovkasm For me this workaround seems to break tests that rely on |
This comment has been minimized.
This comment has been minimized.
@stevehollaar Seems like that, mocks was didn't in test project, so I miss this check. Do you have any suggestions? |
This comment has been minimized.
This comment has been minimized.
stevehollaar
commented
Jul 6, 2018
Sadly I don't have any suggestions on where to go from here, but I added manual mocking to the test repo here: https://github.com/stevehollaar/rn-56-test, so the tests now fail there, since manual mocks are not hoisted. If you're able to get those tests green, that would be wonderful. |
This comment has been minimized.
This comment has been minimized.
Ok. I trying to walk another way and stay with babel-jest (because it automatically adds hoisting plugin). And found that Then I open my
Now all tests pass as expected. So:
Any suggestions what to do welcomed! |
This comment has been minimized.
This comment has been minimized.
After some thinking. We can still apply this patch as a fast workaround (may be even update internal transformer to include hoisting of mocks). In the more far perspective someone should fix jest. What do people think? What the intention of core team? |
This comment has been minimized.
This comment has been minimized.
After tracking history of |
This comment has been minimized.
This comment has been minimized.
@stevehollaar Can you please test? Quick check can be done if you download |
This comment was marked as spam.
This comment was marked as spam.
sync
commented
Jul 10, 2018
any update on this ? |
This comment has been minimized.
This comment has been minimized.
stevehollaar
commented
Jul 10, 2018
@vovkasm Sorry for the delay, but yes! I can confirm that your updated |
This comment has been minimized.
This comment has been minimized.
lehni
commented
Jul 16, 2018
•
@vovkasm did you try and see if using https://github.com/lehni/babel-jest-nested fixes your issue? And if it does, could you maybe add your voice to facebook/jest#6617 to get some traction? |
This comment has been minimized.
This comment has been minimized.
@lehni To be clear... Personally I do not bitten by this error. We use typescript and ts-jest seems work properly (also we do not use jest mocks). But I will look and vote if solution is appropriate ) |
This comment has been minimized.
This comment has been minimized.
Hey @vovkasm just wanted to let you know that I'm trying to get this merged asap but we have been really busy trying to fix RN 0.56 working with Windows. We should be close to a fix for that so hopefully we'll be able to come back to this |
This comment has been minimized.
This comment has been minimized.
evanjmg
commented
Jul 22, 2018
•
so until this is merged, the only workaround is adding this to jest config? React native init creates a broken test suite, should probably merge this asap
UPDATE: I had to copy the preprocessor file and add the mock support to it as seen in the PR. Thanks @vovkasm |
This comment has been minimized.
This comment has been minimized.
@evanjmg Yes, also you can write your own preprocessor (especially if your project uses custom babel configuration). |
This comment has been minimized.
This comment has been minimized.
And I think that sadly this workaround should not be merged, since the issue is actually So tbh I'd prefer to understand and fix why I'll report back here once I have more info/ better ideas. For now I don't want to close this PR as its the only viable workaround. |
This comment has been minimized.
This comment has been minimized.
|
This comment has been minimized.
This comment has been minimized.
Yeah I was using your comments as guidance, thank you so much for your investigations :) And I agree with the preprocessor, not sure if it's there because of some metro requirement but I'll ask around. |
This comment has been minimized.
This comment has been minimized.
Hey @vovkasm I'm closing this for the reasons I mentioned earlier - but I wrote a "more complete" guide to fixing this issue over there #19859 (comment) Thanks again for all your help! |
kelset
closed this
Jul 25, 2018
duranmla
referenced this pull request
Aug 11, 2018
Closed
Upgrade to Babel 7 React Native 0.56 -- Breaking Change #2028
This comment has been minimized.
This comment has been minimized.
fwiw, I just tried this fix out - it seems to not be working (anymore?). this is what my devdeps looks like: "@babel/cli": "7.0.0-beta.47",
"@babel/core": "7.0.0-beta.47",
"@babel/parser": "^7.0.0-beta.48", // there is no beta.47
"babel-core": "7.0.0-bridge.0",
"babel-jest": "^23.4.2", // i'm fairly sure this isn't used
"babel-plugin-jest-hoist": "^23.2.0", I then copied across the Running I've absolutely no idea what's going on here. My metro version is |
This comment has been minimized.
This comment has been minimized.
giancarlo88
commented
Aug 29, 2018
I was also having issues with the internal preprocessor (after applying the fix suggested in #19859 (comment)), because of the missing Doing what @deecewan suggested actually did work for me and fixed the tests that had broken. So if you're struggling like I was it may be worth a try. |
vovkasm commentedJul 6, 2018
Fixes #19859 at least until problem will be fixed properly.
By unknown reason babel-jest can't transform tests and react-native's files, see #19859 for details. But internal preprocessor.js can, so use it for now in published jest-preset.json.
Test Plan:
From original issue:
react-native init Test56 --version=0.56.0
cd Test56
mkdir __tests__
__tests__/AppTest.js
that has following lines:npm test
Slighly modified repo for reproduction: https://github.com/dlowder-salesforce/rn-56-test/tree/eb0611b1870c410cd4a7458a740a3ac52bad2827
Fixed repo: https://github.com/vovkasm/rn-56-test/tree/a00fc639bd6a681591131c24e3ee976ae374438e
@kelset You want to be mentioned ;-)
Release Notes:
[GENERAL] [BUGFIX] [jest-preset.json] - Fix js transformation in jest