Skip to content

Upgrade Jest from 29 to 30 - #2491

Merged
ravikiranvm merged 5 commits into
mainfrom
ops-4816
Sep 10, 2026
Merged

Upgrade Jest from 29 to 30#2491
ravikiranvm merged 5 commits into
mainfrom
ops-4816

Conversation

@ravikiranvm

Copy link
Copy Markdown
Contributor

Fixes OPS-4816.

Supersedes #2485. Dependabot's jest group bump 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 on startup with TypeError: 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:

  • Bump jest-environment-node and jest-environment-jsdom to 30.4.1 so the tree resolves a single jest-mock. This also moves the UI tests from jsdom 20 to jsdom 26.
  • Rename testPathPattern to testPathPatterns in 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.
  • Replace matcher aliases removed in Jest 30 (toThrowError, toBeCalled, toBeCalledWith, toBeCalledTimes) with toThrow and the toHaveBeenCalled* forms across 23 test files.
  • Make the OAuth consent hook test jsdom 26 compatible. jsdom 26 marks window.location non-configurable, so the test can no longer replace it. The redirect now goes through a one-line navigateToExternalUrl helper 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:

Target Result
nx test-unit server-api 97 suites, 962 tests passed, only test/unit files ran
nx test-integration-ce server-api 18 suites, 148 tests passed
nx test-integration-cloud server-api 10 suites, 67 tests passed
nx test react-ui 49 suites, 546 tests passed
nx test ui-components 13 suites, 203 tests passed
nx run-many --target=test (blocks, engine, openops, shared) passed
lint on react-ui, server-api, openops, blocks-anodot clean

Two block suites fail on my machine for reasons unrelated to this change and pass in CI: blocks-date-helper assumes a three-letter short month and my locale is en-IN ("Sept"), and blocks-azure expects the AZURE_EXTENSION_DIR env var that GitHub runners set.

Visual Changes (if applicable)

None.

🤖 Generated with Claude Code

dependabot Bot and others added 3 commits September 8, 2026 08:47
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>
Copilot AI lite review requested due to automatic review settings September 9, 2026 13:47
@linear

linear Bot commented Sep 9, 2026

Copy link
Copy Markdown

OPS-4816

Copilot AI 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.

🟡 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-api Nx Jest targets from testPathPattern to testPathPatterns so Jest 30 correctly scopes unit/integration runs.
  • Extract external navigation to a mockable navigateToExternalUrl helper 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) with jest to 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 testPathPatterntestPathPatterns 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-node are pinned to 30.4.1 while jest is 30.4.2, which can lead to duplicated jest-* 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.

Comment thread package.json
@sonarqubecloud

Copy link
Copy Markdown

@ravikiranvm
ravikiranvm merged commit 68cac4d into main Sep 10, 2026
24 checks passed
@ravikiranvm
ravikiranvm deleted the ops-4816 branch September 10, 2026 12:27
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.

3 participants