Jest: Add .babelrc.js workaround to fix snapshot issues with v28 #13843
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does it do?
Since the
jest@28.x
update we are running into an issue, where updating the snapshots doesn't work any longer, if jest doesn't find the babel configuration, to transform jsx. The tracking issue in jest is open since mid 2021 and it looks like as if nothing changes very soon (the bug was introduced in jest@27).The only known and working solution is to add/ rename the current babel configurations to
.babelrc.js
. As a temporary workaround until the issue is fixed I'd propose we add the missing.babelrc.js
files to each package. I've also pulled out some of the configuration ofadmin
from webpack into the babel configuration, where it imo belongs.In addition, I've removed some transforms which are not needed anylonger, since we are using @babel/preset-env.
Alternative considered: We can not downgrade jest, because we depend on some new features.
Why is it needed?
At the moment we are running into an issue where a snapshot test can not be updated once it is located in a package. Jest will complain that
@babel/preset-react
is not found and fail to update the snapshot.Related issue(s)/PR(s)