It's a bit of a bummer to have to add a babel configuration to my project when there are no explicit references to babel anywhere in my project. If not for a comment linking back to this issue, it would seem like my babel config was doing nothing.

This is happening here -- called from here (i.e. related to the special handling for jest mocks)...but the test file itself has type annotations (.tsx test), which causes babel-jest to throw. If I just run the test file itself through esbuild that works fine.

Our internal oak door collection includes many styles from traditional to contemporary, so you're sure to find a style to suit your home.

We also had to move to swc. Using Babel to pre-transform, which seems foundational concept here, seems defeating the purpose of esbuild.

To repeat, you can't have ock( in your codebase. So the code like function AnythingBlock() immediately triggers the unwanted behavior.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Most designs are available in solid, glazed, bi-folding, fire-rated and French doors allowing you to take a style throughout your home.

So the simplest workaround is to run the babel-typescript transform but of course that defeats the point of this plugin which is to use esbuild to transform the typescript.

So the simplest workaround is to run the babel-typescript transform but of course that defeats the point of this plugin which is to use esbuild to transform the typescript.

Locally, I found that the ReferenceError: React is not defined in TSX files was because the babel transformation would transform the import from import React from 'react' to var _react = _interopRequireDefault(require("react")), but the JSX syntax was being left intact for ESBuild to transform, and it wasn't finding the React symbol.

I think the workarounds are not that appealing. I think the code that looks for the mock calls should probably not do a string search, which feels a bit brittle to me.

my jest tests ran again after renaming setBlock to setBlck. yet, this does not give me a good feeling to use esbuild-jest in production and i'm probably going to move away from esbuild and use swc like @AndrewSouthpaw

thanks @davisford for coming back and posting your solution. I ran into the same issues you did (SynatxError when leaving type annotations in test files, and ReferenceError: React is not defined when using jsx in files that also include jest.mock). I'm curious, did you also only get the ReferenceError in files that included a jest.mock call? Based on the esbuild-jest source you linked to, it seems like that would make sense.

All our interior oak doors have a solid engineered core for superior performance and soundproofing, and an oak veneer, providing a door that looks like solid oak but at a much lower price.

@khalliday7 I don't recall 100% if it occurred just on files that do jest.mock, but I suspect your assumption is correct.

Since only a subset of the files go through the Babel transformation and therefore only some of the files will have React renamed to _react, I don't think you'd be able to fix this by specifying the jsxFactory option on the transformation.

One other workaround we had to do to get past the error ReferenceError: React is not defined in tests was to replace the import React from 'react'; with import * as React from 'react';

in your Babel configuration, it fixed the problem for me without needing to change import styles to import * as React from 'react'.

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

I'm not very familiar with esbuild, I was mostly seeing if I could use it to speed up my Jest test runs, but wouldn't passing the code through a babel transform counteract any speed gains we'd find by using esbuild? Or does it still make a difference?

I tried the workaround (install the plugin @babel/preset-typescript, add to package.json#babel.presets) didn't do the trick, though we don't otherwise have babel set up for anything so maybe that's our issue? Is there any further integration required with jest or esbuild or esbuild-jest?

Internal oak doors are available unfinished allowing you to impart your own style choice, or pre-finished which means that the door has numerous coats of clear lacquer professionally applied and the door is ready to hang on delivery.

Any updates on this issues? We'd like to use esbuild-jest in Payload and I've followed the fixes above, which are great, but I agree that it feels weird to have to add a Babel config to our package.json when we're completely leveraging esbuild at this point.

For us, I can reproduce the problem with a minimal repro, which gives us a SyntaxError, even without type annotations in the test file: