Upgrade Jest from 29 to 30 - #2491
Conversation
Bumps the jest group with 4 updates: [babel-jest](https://github.com/jestjs/jest/tree/HEAD/packages/babel-jest), [jest](https://github.com/jestjs/jest/tree/HEAD/packages/jest), [@types/jest](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/jest) and [ts-jest](https://github.com/kulshekhar/ts-jest). Updates `babel-jest` from 29.7.0 to 30.4.1 - [Release notes](https://github.com/jestjs/jest/releases) - [Changelog](https://github.com/jestjs/jest/blob/main/CHANGELOG.md) - [Commits](https://github.com/jestjs/jest/commits/v30.4.1/packages/babel-jest) Updates `jest` from 29.7.0 to 30.4.2 - [Release notes](https://github.com/jestjs/jest/releases) - [Changelog](https://github.com/jestjs/jest/blob/main/CHANGELOG.md) - [Commits](https://github.com/jestjs/jest/commits/v30.4.2/packages/jest) Updates `@types/jest` from 29.5.14 to 30.0.0 - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/jest) Updates `ts-jest` from 29.4.11 to 29.4.12 - [Release notes](https://github.com/kulshekhar/ts-jest/releases) - [Changelog](https://github.com/kulshekhar/ts-jest/blob/main/CHANGELOG.md) - [Commits](kulshekhar/ts-jest@v29.4.11...v29.4.12) --- updated-dependencies: - dependency-name: babel-jest dependency-version: 30.4.1 dependency-type: direct:development update-type: version-update:semver-major dependency-group: jest - dependency-name: jest dependency-version: 30.4.2 dependency-type: direct:development update-type: version-update:semver-major dependency-group: jest - dependency-name: "@types/jest" dependency-version: 30.0.0 dependency-type: direct:development update-type: version-update:semver-major dependency-group: jest - dependency-name: ts-jest dependency-version: 29.4.12 dependency-type: direct:development update-type: version-update:semver-patch dependency-group: jest ... Signed-off-by: dependabot[bot] <support@github.com>
Dependabot bumped jest, babel-jest, @types/jest and ts-jest but left jest-environment-node and jest-environment-jsdom on 29.7.0, so the environments handed the Jest 30 runtime a Jest 29 module mocker and every server-api suite crashed with "clearMocksOnScope is not a function". Bring both environments to 30.4.1 so the tree resolves a single jest-mock. Jest 30 also renamed testPathPattern to testPathPatterns; the old option was silently ignored, so the server-api unit target ran integration tests too. Replace the removed matcher aliases (toThrowError, toBeCalled, toBeCalledWith, toBeCalledTimes) across the test suites, and move the OAuth consent redirect behind a mockable helper because jsdom 26 no longer allows window.location to be redefined. Fixes OPS-4816. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
|
There was a problem hiding this comment.
🟡 Changes recommended
Jest suite packages are still pinned to mixed patch versions, which can reintroduce multiple resolved Jest internals and undermine the goal of a single consistent runtime/environment setup.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Upgrades the monorepo’s Jest tooling to Jest 30 and updates affected test code/config so CI and local test targets behave correctly (including fixing the prior runtime/environment mismatch and the jsdom 26 window.location constraint).
Changes:
- Upgrade Jest-related dependencies to Jest 30 and update removed matcher aliases across test suites.
- Update
server-apiNx Jest targets fromtestPathPatterntotestPathPatternsso Jest 30 correctly scopes unit/integration runs. - Extract external navigation to a mockable
navigateToExternalUrlhelper and update the OAuth consent hook test to work with jsdom 26.
Blocking
- Align Jest suite package patch versions (
babel-jest,jest-environment-jsdom,jest-environment-node) withjestto avoid resolving multiple versions of Jest internals.
Non-blocking
- None.
Merge recommendation
Do not merge
File summaries
| File | Description |
|---|---|
| packages/server/api/test/unit/trigger-event.service.test.ts | Update toThrowError usage to Jest 30-supported toThrow. |
| packages/server/api/test/integration/ce/authentication/signup.test.ts | Replace deprecated mock matcher alias with toHaveBeenCalledTimes. |
| packages/server/api/test/integration/ce/authentication/signin.test.ts | Replace deprecated mock matcher alias with toHaveBeenCalledTimes. |
| packages/server/api/project.json | Rename Jest 30 option testPathPattern → testPathPatterns for Nx targets. |
| packages/react-ui/src/app/features/oauth/lib/browser-navigation.ts | Add mockable external navigation helper for jsdom 26 compatibility. |
| packages/react-ui/src/app/features/oauth/hooks/use-oauth-consent.ts | Route redirect navigation through the new helper. |
| packages/react-ui/src/app/features/oauth/hooks/tests/use-oauth-consent.test.tsx | Mock navigation at module boundary instead of replacing window.location. |
| packages/openops/test/openops-tables/tables.test.ts | Update deprecated mock matcher aliases to Jest 30 equivalents. |
| packages/openops/test/openops-tables/rows.test.ts | Update deprecated mock matcher aliases to Jest 30 equivalents. |
| packages/openops/test/openops-tables/fields.test.ts | Update toThrowError usage to toThrow and mock matcher aliases. |
| packages/openops/test/openops-tables/application-service.test.ts | Update toThrowError usage to toThrow and mock matcher aliases. |
| packages/openops/test/condition-watcher.test.ts | Update toThrowError usage to toThrow. |
| packages/openops/test/cloud-cli-common.test.ts | Update toThrowError usage to toThrow. |
| packages/openops/test/aws/rds/rds-describe.test.ts | Update deprecated mock matcher aliases to Jest 30 equivalents. |
| packages/openops/test/aws/rds/rds-delete-snapshot.test.ts | Update deprecated mock matcher aliases to Jest 30 equivalents. |
| packages/openops/test/aws/rds/rds-delete-instance.test.ts | Update deprecated mock matcher aliases to Jest 30 equivalents. |
| packages/openops/test/aws/rds/rds-create-snapshot.test.ts | Update deprecated mock matcher aliases to Jest 30 equivalents. |
| packages/openops/test/aws/ec2/ec2-terminate-instances.test.ts | Update deprecated mock matcher aliases to Jest 30 equivalents. |
| packages/openops/test/aws/ec2/ec2-instance-state-manager.test.ts | Update deprecated mock matcher aliases to Jest 30 equivalents. |
| packages/openops/test/aws/ec2/ec2-get-instances.test.ts | Update deprecated mock matcher aliases to Jest 30 equivalents. |
| packages/openops/test/aws/ebs/ebs-get-volumes.test.ts | Update deprecated mock matcher aliases to Jest 30 equivalents. |
| packages/openops/test/aws/ebs/ebs-get-snapshots.test.ts | Update deprecated mock matcher aliases to Jest 30 equivalents. |
| packages/openops/test/aws/ebs/delete-ebs-volume.test.ts | Update deprecated mock matcher aliases to Jest 30 equivalents. |
| packages/openops/test/aws/ebs/delete-ebs-snapshot.test.ts | Update deprecated mock matcher aliases to Jest 30 equivalents. |
| packages/openops/test/aws/ebs/create-ebs-snapshot.test.ts | Update deprecated mock matcher aliases to Jest 30 equivalents. |
| packages/openops/test/auth.test.ts | Update toThrowError usage to toThrow. |
| packages/blocks/anodot/test/common/recommendations.test.ts | Update deprecated mock matcher aliases to Jest 30 equivalents. |
| package.json | Bump Jest-related devDependencies (needs patch-level alignment). |
Review details
Suppressed comments (1)
package.json:395
jest-environment-jsdom/jest-environment-nodeare pinned to 30.4.1 whilejestis 30.4.2, which can lead to duplicatedjest-*internals in the dependency tree. Aligning these to the same patch version reduces the risk of another environment/runtime mismatch.
"jest-environment-jsdom": "30.4.1",
"jest-environment-node": "30.4.1",
- Files reviewed: 28/29 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.



Fixes OPS-4816.
Supersedes #2485. Dependabot's jest group bump left
jest-environment-nodeandjest-environment-jsdomon 29.7.0, so the environments handed the Jest 30 runtime a Jest 29 module mocker and every server-api suite crashed on startup withTypeError: this._moduleMocker.clearMocksOnScope is not a function. Jest 30 is a major release that also needs test code changes, so the upgrade is finished here by hand.Additional Notes
Builds on the Dependabot commits (jest 30.4.2, babel-jest 30.4.1, @types/jest 30.0.0, ts-jest 29.4.12) and adds:
jest-environment-nodeandjest-environment-jsdomto 30.4.1 so the tree resolves a singlejest-mock. This also moves the UI tests from jsdom 20 to jsdom 26.testPathPatterntotestPathPatternsin the three server-api test targets. Jest 30 renamed the option and silently ignored the old name, so the unit target was running integration suites too.toThrowError,toBeCalled,toBeCalledWith,toBeCalledTimes) withtoThrowand thetoHaveBeenCalled*forms across 23 test files.window.locationnon-configurable, so the test can no longer replace it. The redirect now goes through a one-linenavigateToExternalUrlhelper that the test mocks at the module boundary. Hook behavior is unchanged.No product code changes beyond that helper extraction.
Testing Checklist
Check all that apply:
I tested the feature thoroughly, including edge cases
I verified all affected areas still work as expected
Automated tests were added/updated if necessary
Changes are backwards compatible with any existing data, otherwise a migration script is provided
Ran locally on Jest 30:
nx test-unit server-apitest/unitfiles rannx test-integration-ce server-apinx test-integration-cloud server-apinx test react-uinx test ui-componentsnx run-many --target=test(blocks, engine, openops, shared)Two block suites fail on my machine for reasons unrelated to this change and pass in CI:
blocks-date-helperassumes a three-letter short month and my locale is en-IN ("Sept"), andblocks-azureexpects theAZURE_EXTENSION_DIRenv var that GitHub runners set.Visual Changes (if applicable)
None.
🤖 Generated with Claude Code