-
-
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
Tests are failing after upgrade to 0.8.1 #1156
Comments
probably related: #1160 |
I was following the discussion in the thread #1160 and believe that my problem is also related to mentioned Babel issue: babel/babel#4759 Also, I have found that it was introduced by updating preset: Now there are less Babel plugins applied in test environment, but some of them can't still have implicit dependencies on other transformations that was excluded now. @gaearon could you consider rolling this PR back to work around the issue? |
@just-boris yep, that's exactly what we were finding out in #1160, also. So, yep, my advise is that we either:
I'd prefer the first solution. |
I'm happy to push a fix but I want to have an actionable plan for re-enabling
I would prefer this to enabling all of them. There are speed improvements from disabling most transforms, and I don't want to lose them. If something is missing we'll learn about it and file more Babel bugs. It's better than not knowing and learning that the next time we try to enable Would you like to make a PR for adding missing plugins? |
Also, would that help as a temporary workaround? |
It doesn't seem to work in my case.. |
Just saw this - so tried to repro from scratch
I added a test to
and it passes for me with but maybe it was just that code? |
env means that you shouldn't need regenerator at all because you are using -env? (which just uses async-to-gen) |
Ok that errors - it's a different error than the OP's error. And i'm pretty sure it's just because regenerator is being run from another plugin somehow because if you are using node 6.9.0 it wouldn't be running it via babel-preset-env which is the point |
@hzoo I already tried to disable
and
errors. |
https://github.com/facebookincubator/create-react-app/blob/11cd813802153a5de0ec1d60ea764fd1b26be8c8/packages/babel-preset-react-app/index.js#L26-L30, it's included in plugins all the time so we wouldn't want this if we are also using env. Otherwise it wouldn't compile async since it says async: false |
Basically what I think we need to do is make sure the So at the very least remove |
I followed the same steps, (except that I have node 6.9.1) and got the error. Does it help you if will send the result |
@just-boris can you comment out regenerator in https://github.com/facebookincubator/create-react-app/blob/11cd813802153a5de0ec1d60ea764fd1b26be8c8/packages/babel-preset-react-app/index.js#L26-L30 in node_modules? It should work |
I cloned the repo you linked and commented it out and it worked. Maybe rerun |
I can confirm that commenting out regenerator fixes it('async test', async () => {
const {result} = await doSometing(); // Note: MUST have await to reproduce
}); for me. Before commenting it I was seeing
but not anymore. One thing to keep in mind is there's some Jest caching going on so you need to change something in test file every time you try after changing preset. |
Yes, it fixes that error, but not the other ones |
Ok then that's a different issue and unrelated to what was reported above? I didn't know when you said it doesn't work what you meant
I don't see that in the repo you posted? |
you are right, I'm trying to get on that repo all the errors I'm finding in my codebase, I'll update it asap |
This file compiles for me after removing regenerator on Node 6.9.1: import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
function doSometing() {
return {};
}
const getId = async () => {
const { id } = await dispatch(42)
return id
};
const getId2 = async () => {
const p = await dispatch(42)
const { id } = p
return id
};
function Record() {
return function() {}
}
const User = new Record({ id: NaN })
new User({ id: 42 })
it('async test', async () => {
const {resultxx} = await doSometing();
}); What are other cases? That’s all I could find from this issue and #1160. |
I can confirm var addIndex = function addIndex({ index, ...routes } = {}, base) {
}; is not working.
|
Oh right that specifically babel/babel#4851! Haven't had time to fix but can work on that (edge cases in the object-rest-spread transforms) |
Can you provide any other cases for future reference? I'll keep parameters and destructuring for babel/babel#4851 but I need to know if there's anything else failing. All of #1156 (comment) appears solved by excluding regenerator from default transform. |
@gaearon I'm still having the |
@EnoahNetzach Could it be related to anything else in that file? Maybe you need the whole file (with variable bindings) to reproduce some corner case. |
@EnoahNetzach Any chance you're also seeing Babel/Jest caching? You'd need to modify the test file to make sure your config changes are picking up. |
@gaearon sorry, I confirm everything works for me without (I was commenting out |
@EnoahNetzach I'm on it, will send something soon for you to review |
@gaearon great ;) |
So there are 2 separate issues? one relating to -env and regenerator and the other is using object-rest-spread and there being a bug with the standalone plugin. You should be able to to just remove regenerator since it's included in both env/latest already and then add destructuring/parameters. Not sure why you need arrow-functions? |
If I recall correctly I am explicitly including together with It indeed appears unnecessary with |
@hzoo @EnoahNetzach @just-boris Ready for review: |
@gaearon Thanks! |
Works well. |
I'll make a release in a day or two but I hope to fix a few more bugs. Definitely this week. |
Fixed in 0.8.2. https://github.com/facebookincubator/create-react-app/releases/tag/v0.8.2 |
Still getting
in VS code jest extension but works on in terminal. |
Likely some caches. I'm not sure where exactly Jest keeps its cache but try clearing stuff in |
@gaearon I opened up jestjs/jest#2231 - to default to |
Right now it should be located in |
yes, but clearing cache does not solve the vscode jest extensions problem. Filed a bug over there. |
If you are reporting a bug, please fill in below. Otherwise feel free to remove this template entirely.
Can you reproduce the problem with latest npm?
I have Yarn installed, so CRA used latest [email protected] to setup.
Description
My test command fails with the following error
It worked fine with version 0.7.0, today I tried to upgrade to latest 0.8.1 and got the error above.
I have generated new test application with latest
create-react-app
andreact-scripts
and could find a minimal example to reproduce.Add the following test in your test files, then run
npm test
.Basically, destructuring assignment doesn't work in
async
function with Jest.Babel Repl transpiles this code fine. Also it works fine if I will put this code into source. Problem appears only in testing code.
Expected behavior
I expect that it works as it was before in 0.7.0
Actual behavior
Tests are not run, error appears before any test starts.
Environment
Run these commands in the project folder and fill in their results:
npm ls react-scripts
(if you haven’t ejected):node -v
:npm -v
:Then, specify:
The text was updated successfully, but these errors were encountered: