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

Async Jest tests run into issue #18

Open
jordan-cote opened this issue Mar 12, 2021 · 3 comments
Open

Async Jest tests run into issue #18

jordan-cote opened this issue Mar 12, 2021 · 3 comments
Labels
bug Something isn't working

Comments

@jordan-cote
Copy link

jordan-cote commented Mar 12, 2021

Hi, thanks for this project!
I'm having an issue I can't seem to fix: all my Jest tests are passing BUT as soon as there is some async in there, it stops working, having a ReferenceError: regeneratorRuntime is not defined.

script in package.json: craco test

Here is my craco.config.js:

const CracoEsbuildPlugin = require('craco-esbuild');

module.exports = {
  plugins: [{
    plugin: CracoEsbuildPlugin, options: {
      esbuildLoaderOptions: {
        loader: 'jsx',
        target: 'es2015',
      }
    }
  }]
};

Error:
image

And when I run it with a Jest configuration (with Babel) there is no issue. Any leads?
Thanks!

edit: I dug into the issue and the case is well documented for Babel, needing to add polyfill and/or regenerator. But having low experience with esbuild, I don't know how the polyfills work, especially with create-react-app-esbuild as a wrapper.

@pradel pradel added the bug Something isn't working label Mar 12, 2021
@jordan-cote
Copy link
Author

jordan-cote commented Mar 14, 2021

Update: running with the jest script after installing esbuild-jest(by putting esbuild-jest as transform in jest.config.js) seems to be working. Although this is a quick fix, this must mean there is indeed a bug with this craco. Ideally I would only have to run craco test and it should work.

Let me know if you need more info 👍

@pradel
Copy link
Owner

pradel commented Apr 28, 2021

I would be curious to see this one, do you have a reproducible example so I can fix the issue?

@jordan-cote
Copy link
Author

I would be curious to see this one, do you have a reproducible example so I can fix the issue?

Semester's over in a few days, then I should be able to give you a minimal project to reproduce this, sure

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants