Skip to content

build: upgrade jest to 30 - #3413

Open
aresnik11 wants to merge 13 commits into
mainfrom
ajr-bump-jest
Open

build: upgrade jest to 30#3413
aresnik11 wants to merge 13 commits into
mainfrom
ajr-bump-jest

Conversation

@aresnik11

@aresnik11 aresnik11 commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Overview

Bumps the Jest core family to v30 (from v29) across the monorepo, along with the companion updates required to keep the test suite green on the new major.

Changes

  • Jest 30 — bumped jest, jest-cli, jest-config, jest-environment-jsdom, and related core packages to v30.
  • testing-library refresh — updated @testing-library/* to versions compatible with Jest 30 / jsdom 26.
  • jest-dom v7 — replaced removed matcher aliases and fixed the Modal primary-variant test for the new matcher behavior.
  • Types — added explicit @types/jest (no longer bundled the way v29 provided it).
  • Removed unused deps — dropped jest-environment-jsdom-global (peer-capped at jest 29), @testing-library/react-hooks (renderHook now comes from RTL), and mutationobserver-shim (jsdom 26 has native MutationObserver).
  • Snapshots — updated snapshot headers for the jest 30 format.
  • Config loader pin — added the /** @jest-config-loader ts-node */ pragma to all 9 package jest.config.ts files (see below).

Why the config-loader pragma

Jest 30 changed how it loads .ts config files: on Node versions with native TypeScript support (process.features.typescript, default-on in Node ≥ 22.18 / 23.6 / 24) it loads the config as native ESM instead of via ts-node/CJS.

Our package configs rely on CJS-only idioms — an extensionless import base from '../../jest.config.base' and __dirname in jest.config.base.ts — which are illegal under ESM. The result was a hard split:

  • Devs on older Node (e.g. the repo's pinned ^22.13.1) → ts-node/CJS path → tests pass.
  • Devs on Node ≥ 22.18 → native ESM path → every project fails with Jest: Failed to parse the TypeScript config file … ERR_MODULE_NOT_FOUND: Cannot find module '…/jest.config.base'.

The @jest-config-loader ts-node pragma forces the ts-node/CJS loader on all Node versions, making config loading consistent for everyone without rewriting the configs to be ESM-native (which would have required dropping ts-node and bumping the pinned Node).

PR Checklist

  • Related to designs:
  • Related to JIRA ticket: GMT-237
  • Version plan added/updated (or not needed)
  • I have run this code to verify it works
  • This PR includes unit tests for the code change
  • This PR includes testing instructions tests for the code change
  • The alpha package of this PR is passing end-to-end tests in all relevant Codecademy repositories

Testing instructions

# Install the updated deps
yarn install

# Run the full test suite across all projects
yarn test
# (equivalently: yarn nx run-many --target=test --all)

# Typecheck
yarn verify

Expected: all 9 projects green (1587 tests pass, 0 fail), typecheck clean, and a clean working tree afterward (no snapshot churn).

PR Links and Envs

Repository PR Link
Monolith Monolith PR
Mono Mono PR

aresnik11 and others added 7 commits August 18, 2026 09:32
jest/jest-environment-jsdom 29.6.4 -> 30.x, babel-jest 29.6.4 -> 30.4.1,
ts-jest -> ^29.4.12 (supports jest 30; ts-jest 30 unpublished). Pulls in jsdom 26.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Drop jest-environment-jsdom-global (unused; peer capped at jest 29),
@testing-library/react-hooks (unused; renderHook comes from RTL), and
mutationobserver-shim (jsdom 26 has native MutationObserver).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@testing-library/jest-dom ^5.16 -> ^7 and @testing-library/dom ^8 -> ^10
to align with jest 30 / RTL 15 / jsdom 26 (jest-dom v7 requires node 22).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The jest global types (describe/it) were only present transitively before;
removing the unused deps dropped @types/jest, breaking tsconfig types:[jest].
Pin it explicitly at ^30 to match jest 30.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Jest 30 removed the alias matchers. toBeCalled -> toHaveBeenCalled and
lastCalledWith -> toHaveBeenLastCalledWith across Disclosure, GridForm,
and useDebouncedField tests.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The single-view config disabled the next CTA (last view), so jest-dom v7's
accurate toHaveStyle read the disabled background. Add a second view so the
next button is enabled and its primary variant is actually asserted.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Jest 30 changed the snapshot header URL (goo.gl -> jestjs.io); no content drift.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@nx-cloud

nx-cloud Bot commented Aug 18, 2026

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit 3fb3319


☁️ Nx Cloud last updated this comment at 2026-08-24 14:13:31 UTC

@aresnik11 aresnik11 changed the title Ajr bump jest build: bump Jest Aug 18, 2026
@codecov

codecov Bot commented Aug 19, 2026

Copy link
Copy Markdown

⚠️ JUnit XML file not found

The CLI was unable to find any JUnit XML files to upload.
For more help, visit our troubleshooting guide.

@aresnik11 aresnik11 changed the title build: bump Jest build: upgrade jest to 30 Aug 19, 2026
@aresnik11
aresnik11 marked this pull request as ready for review August 19, 2026 18:38
@aresnik11
aresnik11 requested a review from a team as a code owner August 19, 2026 18:38
Comment on lines +372 to +380
{
title: 'Multi view',
children: <>View 2</>,
primaryCta: { actionType: 'confirm', children: 'Done' },
secondaryCta: {
actionType: 'cancel',
children: 'Cancel',
},
},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this seems out of place, why did this need to change?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

oh! it was a real test failure where the next button was disabled bc it was testing multiview with only one view. selling the jest bump with this one example!

@dreamwasp dreamwasp left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

these are failing for me locally -

Image

@aresnik11
aresnik11 marked this pull request as draft August 19, 2026 19:29
@aresnik11

Copy link
Copy Markdown
Contributor Author

these are failing for me locally -

Image

apparently its related to node version! im on 22.14.0 and its working. looking into it! explanation: Jest 30 loads a .ts config natively as ESM whenever Node reports native TypeScript support (process.features.typescript), which is default-on in Node ≥ 22.18 / 23.6 / 24. You're on 22.14 (flag off) so jest quietly uses ts-node/CJS and everything resolves. Coworkers on newer Node get the ESM loader, where extensionless imports (and __dirname) are illegal → the config fails to parse → every project's tests fail.

aresnik11 and others added 5 commits August 20, 2026 16:36
Jest 30 loads .ts configs as native ESM on Node >=22.18/23.6/24
(process.features.typescript), where the configs' extensionless base
import and __dirname break. Pin the ts-node/CJS loader via the
@jest-config-loader pragma so config loading is consistent across
Node versions.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@codecademydev

Copy link
Copy Markdown
Collaborator

📬 Published Alpha Packages:

Package Version npm Diff
@codecademy/gamut 73.0.1-alpha.165d55.0 npm diff
@codecademy/gamut-icons 10.0.1-alpha.165d55.0 npm diff
@codecademy/gamut-illustrations 1.0.1-alpha.165d55.0 npm diff
@codecademy/gamut-kit 3.0.18-alpha.165d55.0 npm diff
@codecademy/gamut-patterns 1.0.1-alpha.165d55.0 npm diff
@codecademy/gamut-styles 21.0.1-alpha.165d55.0 npm diff
@codecademy/gamut-tests 7.0.1-alpha.165d55.0 npm diff
@codecademy/variance 1.0.1-alpha.165d55.0 npm diff
eslint-plugin-gamut 3.0.1-alpha.165d55.0 npm diff

@github-actions

Copy link
Copy Markdown
Contributor

@aresnik11
aresnik11 marked this pull request as ready for review August 24, 2026 14:39
@aresnik11
aresnik11 requested a review from dreamwasp August 24, 2026 14:39

@LinKCoding LinKCoding left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Tests are passing and type checking looks good!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants