Skip to content
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

Error when testing async generator #4936

Closed
crubier opened this issue Nov 22, 2017 · 4 comments
Closed

Error when testing async generator #4936

crubier opened this issue Nov 22, 2017 · 4 comments

Comments

@crubier
Copy link

crubier commented Nov 22, 2017

This is a potential bug with jest / babel-jest

What is the current behavior?

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

Setup

npm install

Problem

  • 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.

Error given by jest:

 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>

My Configuration

See package.json in my repo

  • Mac OS High sierra
  • Node v8.6.0
  • NPM v 5.5.1
  • Babel-jest v21.2.0
  • Jest v21.2.1
@crubier
Copy link
Author

crubier commented Nov 22, 2017

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

crubier/jest-bug@ea0fa24

@yaelhe
Copy link

yaelhe commented Mar 16, 2018

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.
yaelhe/jest-bug@31bb5a1

@thymikee
Copy link
Collaborator

Thank you @yaelhe!

@github-actions
Copy link

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.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants