-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
Async Iterators don't work #6492
Comments
@pranaygp tried testing async function on node 10.5.0 and it is working fine. |
@ASHISH932 I'm dealing with the exact same case as @pranaygp described and |
I've been able to get this working by:
After that, I got expected behavior. Having said that, I think that if those async generators and async iteration are natively supported by node starting from 10.5.0 tools like jest should support them out of box as well. |
@nooga you should be using env preset of babel(babel-preset-env) as it's support latest javascript feature, whenever it's get official . Here is an article to set up your react environment. |
@ASHISH932 Thanks, although I don't use babel in my project directly and it has absolutely nothing to do with react. |
@nooga that's up to you to decide architecture of your project but if you read documentation of jest they have mentioned to use env preset |
@ASHISH932, I am using node 10.5. Still getting the error after I added a .babelrc.js (below). How do you suggest using babel-preset-env?
EDIT Possibly related to the fact that I am using ts-jest, which skips babel -- kulshekhar/ts-jest#471 (comment) AFAIK this should work without babel if node accepts without babel. |
Node does support async generators starting from version 10.3. @shaunc if you are using babel this comment #4936 (comment) might be helpful for you |
This is essentially the same issue as #6829. tl;dr: Jest uses babel by default, so you have to tell it to understand your syntax or explicitly disable babel. You can follow babel/babel#7660 for what I think is the correct solution to this problem |
@SimenB in kulshekhar/ts-jest#471 the problem is that ts-jest passes typescript compiler results to jest without using babel by default. So
doesn't actually work, but it should |
That's something that should be addressed in ts-jest then. Remember that Babel is needed for code coverage, though. |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
🐛 Bug Report
Async Iterators or generators simply don't work with jest even thought they're natively supported in Node 10
To Reproduce
cd
to a test project wherejest
worksasync function* foo() {}
to some fileyarn start
ornode index.js
etc.)yarn test
*
"Expected behavior
The test suite should run normally and not throw this error
Link to repl or repo (highly encouraged)
Seems like repl.it doesn't have node 10. Sorry :/
Issues without a reproduction link are likely to stall.
Run
npx envinfo --preset jest
Paste the results here:
The text was updated successfully, but these errors were encountered: