-
-
Notifications
You must be signed in to change notification settings - Fork 26.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
Upgrade jest from 26.6.0 to 27.0.0-next.6 #10748
Conversation
Hi @ankurkaushal! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at [email protected]. Thanks! |
Looking into the CI failures. 👀 |
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks! |
I guess the tests are failing because of this file https://github.com/facebook/create-react-app/blob/master/packages/react-error-overlay/src/utils/getSourceMap.js#L117 accessing the window object which doesn't exist on the node environment. I could add the code below to this file https://github.com/facebook/create-react-app/blob/master/packages/react-error-overlay/src/__tests__/get-source-map.js in order to properly setup the correct environment. /**
* @jest-environment jsdom
*/ |
@renatoalencar Hmm, now it worked & the test in question is passing 🤔 Looks like I was missing the upgrade in rest of the packages in 3f03a63 |
@SimenB: Seeing a different error now:
|
If we're seen errors we are having some progress. Now it looks like this file https://github.com/facebook/create-react-app/blob/master/packages/react-scripts/config/jest/babelTransform.js is doing a require on an ES module, which export things on a default property. |
This is the import const babelJest = require('babel-jest'); This is what is being exported export default transformer; If you put a default property at the end of the require call it should probably work. Like this const babelJest = require('babel-jest').default; |
@renatoalencar That worked! Thank you catching that :) |
@ankurkaushal Btw thank you for quickly jumping on this, it's really appreciated. |
@gaearon: My pleasure, always happy to help & I didn't want to miss an opportunity to collaborate with you! I see a lot of checks are still failing, looks like something to do with fixtures? Would re-running jest with |
What is the error? |
Is this what you're seeing too?
|
No actually, I ran that & it just ran the server & quit. |
Since some of those tests are testing the testing environment (this sound funny), I think you should probably change those to match the requirements of this new version of Jest. Since this is a breaking change in Jest, it would make sense to break something like this. What do you think @gaearon? Can you run e2e tests locally @ankurkaushal? |
@renatoalencar: Yep I can run it via |
I'll run it here too and see what I find. |
@renatoalencar: Only error I see is this:
What about you? |
Yeah, same thing here 😞. Let's check for behavior first, then all the cases. |
@SimenB there's a lot of timeouts on the CI logs, do you have any idea why? |
Nope, I have no idea what the tests are doing |
This specific test case is timing out, but there's I'm trying increasing directly on the file, let's see if that works. |
00e0408
to
70fb0b8
Compare
Updated to new version of For example, I get this error in FAIL template/src/App.test.js
● Test suite failed to run
Jest encountered an unexpected token
Jest failed to parse a file. This happens e.g. when your code or its dependencies use non-standard JavaScript syntax, or when Jest is not configured to support such syntax.
Out of the box Jest supports Babel, which will be used to transform your files into valid JS based on your Babel configuration.
By default "node_modules" folder is ignored by transformers.
Here's what you can do:
• If you are trying to use ECMAScript Modules, see https://jestjs.io/docs/ecmascript-modules for how to enable it.
• To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" in your config.
• If you need a custom transformation specify a "transform" option in your config.
• If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper" config option.
You'll find more details and examples of these config options in the docs:
https://jestjs.io/docs/configuration
For information about custom transformations, see:
https://jestjs.io/docs/code-transformation
Details:
SyntaxError: /Users/ankurkaushal/projects/create-react-app/packages/cra-template/template/src/App.test.js: Support for the experimental syntax 'jsx' isn't currently enabled (5:10):
3 |
4 | test('renders learn react link', () => {
> 5 | render(<App />);
| ^
6 | const linkElement = screen.getByText(/learn react/i);
7 | expect(linkElement).toBeInTheDocument();
8 | });
Add @babel/preset-react (https://git.io/JfeDR) to the 'presets' section of your Babel config to enable transformation.
If you want to leave it as-is, add @babel/plugin-syntax-jsx (https://git.io/vb4yA) to the 'plugins' section to enable parsing.
at Parser._raise (../../node_modules/@babel/parser/src/parser/error.js:134:45)
at Parser.raiseWithData (../../node_modules/@babel/parser/src/parser/error.js:129:17)
at Parser.expectOnePlugin (../../node_modules/@babel/parser/src/parser/util.js:191:18)
at Parser.parseExprAtom (../../node_modules/@babel/parser/src/parser/expression.js:1212:18)
at Parser.parseExprSubscripts (../../node_modules/@babel/parser/src/parser/expression.js:616:23)
at Parser.parseUpdate (../../node_modules/@babel/parser/src/parser/expression.js:596:21)
at Parser.parseMaybeUnary (../../node_modules/@babel/parser/src/parser/expression.js:563:23)
at Parser.parseExprOps (../../node_modules/@babel/parser/src/parser/expression.js:367:23)
at Parser.parseMaybeConditional (../../node_modules/@babel/parser/src/parser/expression.js:332:23)
at Parser.parseMaybeAssign (../../node_modules/@babel/parser/src/parser/expression.js:287:21) Am I missing something here with the |
5e6faa2
to
e14da91
Compare
Upgrades from 27.0.1 to 27.0.3
Latest Update: Updated to new version of
Not sure if my machine has something funky going on or is there anything else I need to double check? Would appreciate another pair of eyes on this. |
@ankurkaushal how do you test this branch? Would love some advice on that, I'll try to use 27.0 jest versions. |
For the first error and the third error, add I'm not sure whether jest can find that jest.config.js by itself. You may need to execute BTW, you forgot to upgrade |
I'm going to close this in favour of #11338 since the tests are all passing in that PR. Thank you for your contribution. |
Closes #10747. Fixes #9993.