Open joaocasarin opened 2 years ago
Have you found a solution to this? I'm also facing this problem.
Hi @sambs sorry not answering this earlier, I know it's been months but I have stopped working on my project using esbuild and esbuild-jest, but I just started it again and I hope someone can help us. Unfortunately I haven't found a solution for this yet, it seems to be a real issue with esbuil-jest.
Apparently no one answered this issue and no other new issues were raised, but would you or any other contributor mind helping us please? @aelbore
I think the problem sits with Jest itself that has not finished its migration to ESM yet. You can follow the progress here: https://github.com/facebook/jest/issues/9430
Hopefully, Jest will switch to esbuild
deprecating this module since nowaday, babel is probably a bit overkill for modern development and damn slow after tasting esbuild ;).
I think the problem sits with Jest itself that has not finished its migration to ESM yet. You can follow the progress here: https://github.com/facebook/jest/issues/9430
Hopefully, Jest will switch to
esbuild
deprecating this module since nowaday, babel is probably a bit overkill for modern development and damn slow after tasting esbuild ;).
But if it were a problem with jest itself, then @swc/jest shouldn't be able to run the testing using that config, right?
@joaocasarin it is due to this : https://github.com/aelbore/esbuild-jest/issues/54
Once a jest.mock is detected, it fallbacks to using Babel which leads to syntax errors.
Well, the error is pretty auto-describable.
To perform unit tests with
Prisma
, we need to mock thePrismaClient
, and for that we use the packagejest-mock-extended
and its methodmockDeep
overPrismaClient
. However, if I want to use the transformeresbuild-jest
instead of the traditionalts-jest
, it fails exactly on the line wheremockDeep<PrismaClient>()
is called.Packages versions:
Repository to reproduce the error: fail_esbuild-jest_with_prisma
Steps to reproduce:
1. Install dependencies
2. Run tests using
ts-jest
3. Run tests using
esbuild-jest
Expected results
Both should succeed and show the following output:
Current results with esbuild-jest
However, the second one -
esbuild:test
is failing with the following output: