-
Notifications
You must be signed in to change notification settings - Fork 308
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
[Bug]: TypeError: configSet.processWithEsbuild is not a function #2117
Comments
Hello, I am facing the same issue right now. I have the same configuration as you have. |
There is something with |
Same here, we are able to run tests with .js configs, but .ts is not working :( |
Hi, does this problem still occur with latest version? |
Seem be fixed for me 👍 |
Version
13.1.1
Steps to reproduce
Setup an angular repository with
jest.config.ts
, notjest.config.js
, jest-preset-angular, and a single test.Expected behavior
The test runs
Actual behavior
TypeError: configSet.processWithEsbuild is not a function
Additional context
Upgrading to
@angular-builders/jest
16.0.0-beta.0
I encountered an errorTypeError: configSet.processWithEsbuild is not a function
. (see just-jeb/angular-builders#1354)I got my best debugger out and searched for the origin of this bug. I think that
jest-preset-angular
(probably versions 12+) is incompatible with Jest Typescript configuration files such asjest.config.ts
andsetupTest.ts
.The reason is the following.
jest
, thents-jest
transforms one of these two files (jest.config.ts
andsetupTest.ts
), it will instantiateTsJestTransformer
and call_configsFor
. Since no_cachedConfigSets
exists,TsJestTransformer
will create one.jest
moves to the Angular files. It properly transforms them withNgJestTransformer
, which relies onsuper._configsFor
to call the configuration. However, it expects that no configuration will exist and that this function will be called instead to set the configset to aNgJestConfig
(that contains the attributeprocessWithEsbuild
):NgJestConfig
is never created as there is already one item in_cachedConfigSets
for the same configuration. HenceprocessWithEsbuild
does not exist in theconfigSet
and the lineif (configSet.processWithEsbuild(filePath)) {
will fail with the errorTypeError: configSet.processWithEsbuild is not a function
Reverting both
jest.config.ts
andsetupTest.ts
to plain Javascript files solves the issue (reverting onlyjest.config.ts
does not) and the tests runs normally. This makes it probable that using the private cache is not a reliable method to add new parameters. Turns out, [this line already acknowledges](https://github.com/thymikee/jest-preset-angular/blob/2ad157d4a3e9130a8913561a57ec5931ef3e0ec4/src/ng-jest-transformer.ts#LL53C5-L53C102) that using the cache is dangerous and could lead to some problems. I suppose we should find another way to provide theprocessWithEsbuild
option in the configuration but I’ll leave it to the maintainers as I don’t know the ecosystem well enough to weigh in.Environment
The text was updated successfully, but these errors were encountered: