-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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]: Missing docs for SyncTransformer#createTransformer #12403
Comments
Yeah, this is so that you can have transformer config in your jest config, and it is passed at runtime. You should call This of course should be documented though. Any help with that would be highly appreciated 😀 |
I have no issues in documenting it, I was just not sure what to write, but now I have deep dived into Looking into the validation errors and associated tests, it seems the interfaces should be updated as well? This is what I seem to understand is lacking documentation (as explicit docs or via typing):
Suggested changes
The last point would potentially be breaking, so for backwards compatibility could be 👍 / 👎 ? |
Supplying However, we have both sync (
Ish,
Agreed!
As mentioned,
👍
👎
👍
We're currently releasing alphas for Jest 28, so breaking changes are fine 🙂 |
Basically conclusions from a discussion in jestjs#12403
Basically conclusions from a discussion in jestjs#12403
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days. |
I think this was fixed in #12407 |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Version
27.5.1
Steps to reproduce
I created a minimal repro repo before figuring out what was wrong, but the essence is this:
Create a
debug-transformer.js
that wraps another, like this wrappingbabel-jest
:and use it in the jest config:
Now, when running
DEBUG="jest-debug*" npx jest --no-cache
I would have assumed it would print messages such as "Transforming './src/myfile.test.tsx'", but it never does. Unless I manually add a line where Idelete module.exports.createTransformer
, that is.Expected behavior
I would have expected it to use the implemented
process
andprocessAsync
methods when implemented, as the effects ofcreateTransformer
is not documented.Actual behavior
createTransformer()
is being called if present. This is not documented in the transform docs, and makes the interface not really reflect reality. There is no point in implementingprocess
if it is never called.Additional context
I have been looking into/debugging code transformation related issues in Jest for the last day and a recurring theme is that the
SyncTransformer#createTransformer
method is a constant source of surprise and it is not really documented why it exists.The
SyncTransformer
interface only has a single field one has to implement:process
. But it seems that if one implementscreateTransformer
those other methods will not be used: instead Jest seems to create a new transformer usingcreateTransformer
, which caused my to lose a few hairs until I figured what was going on. This behaviour does not seem to be documented.The
babel-jest
source for Jest 27.Environment
System: OS: macOS 12.2 CPU: (8) arm64 Apple M1 Binaries: Node: 17.4.0 - /usr/local/bin/node npm: 8.3.1 - /usr/local/bin/npm npmPackages: jest: ^27.5.1 => 27.5.1
The text was updated successfully, but these errors were encountered: