create-react-app-esbuild
create-react-app-esbuild copied to clipboard
Async Jest tests run into issue
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:
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.
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 👍
I would be curious to see this one, do you have a reproducible example so I can fix the issue?
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