Skip to content
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

Jest: Add .babelrc.js workaround to fix snapshot issues with v28 #13843

Closed
wants to merge 1 commit into from

Conversation

gu-stav
Copy link
Contributor

@gu-stav gu-stav commented Jul 25, 2022

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 of admin 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)

@gu-stav gu-stav added source: tooling Source is GitHub tooling/tests/ect pr: fix This PR is fixing a bug labels Jul 25, 2022
@gu-stav gu-stav added this to the 4.3.0 milestone Jul 25, 2022
@codecov
Copy link

codecov bot commented Jul 25, 2022

Codecov Report

Merging #13843 (5384418) into master (661281b) will not change coverage.
The diff coverage is n/a.

❗ Current head 5384418 differs from pull request most recent head c8e7c81. Consider uploading reports for the commit c8e7c81 to get more accurate results

@@           Coverage Diff           @@
##           master   #13843   +/-   ##
=======================================
  Coverage   54.34%   54.34%           
=======================================
  Files        1190     1190           
  Lines       30194    30194           
  Branches     5470     5470           
=======================================
  Hits        16409    16409           
  Misses      12008    12008           
  Partials     1777     1777           
Flag Coverage Δ
front 56.55% <ø> (ø)
unit 48.68% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...es/core/admin/admin/src/pages/ProfilePage/index.js 67.69% <ø> (ø)
.../SettingsPage/pages/Users/EditPage/utils/layout.js 0.00% <ø> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 661281b...c8e7c81. Read the comment docs.

@gu-stav gu-stav changed the title Jest: Add .babelrc.js workaround Jest: Add .babelrc.js workaround to fix snapshot issues with v28 Jul 25, 2022
@ronronscelestes
Copy link
Contributor

Tested on a branch with the updated DS - it seems to have fixed the issue of not being able to update snapshots, thank you 🙏🔥

@Convly Convly self-requested a review July 26, 2022 08:47
Copy link
Member

@Convly Convly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Convly Convly modified the milestones: 4.3.0, 4.3.1 Jul 27, 2022
@gu-stav gu-stav closed this Jul 27, 2022
@gu-stav gu-stav deleted the fix/jest-28-workaround-babel branch July 27, 2022 13:16
@alexandrebodin alexandrebodin modified the milestones: 4.3.1, 4.3.2 Aug 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr: fix This PR is fixing a bug source: tooling Source is GitHub tooling/tests/ect
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants