This is a potential bug with jest / babel-jest
Jest does not seem to support testing async generators.
Everything is explained on this repo I made for the occasion:
https://github.com/crubier/jest-bug
npm install
npm run test-no-jest succeeds, it runs the test without any test framework, just using asserts.npm run test fails because of the async generator but it should not. FAIL src/__tests__/basics.js
✕ async generator (1ms)
● async generator
TypeError: iterable[Symbol.iterator] is not a function
at _asyncIterator (src/__tests__/basics.js:3:421)
at _callee2$ (src/__tests__/basics.js:36:138)
at step (src/__tests__/basics.js:3:663)
at src/__tests__/basics.js:3:893
at Promise (<anonymous>)
at Object.<anonymous> (src/__tests__/basics.js:3:574)
at Promise (<anonymous>)
at <anonymous>
See package.json in my repo
Found a fix to this bug, but I believe it should be solved another way within babel-jest.
The solution was to require babel-polyfill from a Jest setupFile.
Here is the commit of the solution
https://github.com/crubier/jest-bug/commit/ea0fa2452e6d40d4e61cc0a412fcc341131ec718
Hey @crubier @thymikee 👋
This is now fixed with babel 7.0.0-beta.41 🎉
I created a commit on a fork of your repo so you can see what changes you should do (in devDependencies & .babelrc). You'll need to upgrade to babel 7 and @babel/preset-env should be configured with shippedProposals and use-builtins.
https://github.com/yaelhe/jest-bug/commit/31bb5a10069a98ed1da58e13ee21c7d6fd782e97
Thank you @yaelhe!
Most helpful comment
Found a fix to this bug, but I believe it should be solved another way within
babel-jest.The solution was to require
babel-polyfillfrom a JestsetupFile.Here is the commit of the solution
https://github.com/crubier/jest-bug/commit/ea0fa2452e6d40d4e61cc0a412fcc341131ec718