console icon indicating copy to clipboard operation
console copied to clipboard

CONSOLE-4970: Upgrade Jest from 22 to 30

Open logonoff opened this issue 1 month ago โ€ข 12 comments

Summary

  • Upgrade Jest from version 22.4.3 to 30.2.0
  • Update all test configurations for Jest 30 compatibility
  • Fix ES module mocking issues with jest.mock pattern changes
  • Switched to @swc/jest to increase unit test execution speed. This gives us ~3.7x speedup compared to our existing test suite (See https://github.com/openshift/console/pull/13986 -- with ts-jest, the test suite becomes unreasonably slow after the jest bump)

Key Changes

  • Replace jest.spyOn with jest.mock for ES module exports
  • Update transformIgnorePatterns to include ESM modules (jsonpath-plus, nanoid, @rjsf)
  • Updated jest.fn<Type>() syntax to use new type parameters
  • Change toBeCalled() to toHaveBeenCalled() (deprecated)
  • Keep node-fetch polyfill in before-tests.js for nock v11 compatibility with jsdom

Skipped Tests Added in This PR

1. plugin-loader.spec.ts - describe.skip('loadAndEnablePlugin')

Reason: ES module mocking limitation. loadAndEnablePlugin internally calls loadDynamicPlugin within the same module. With ES modules, internal function calls bypass the mock. Next Steps:

  • Refactor production code to use dependency injection
  • OR delete when migrating to https://github.com/openshift/dynamic-plugin-sdk/

2. active-plugins.spec.ts - 2 tests skipped

Reason: These tests mock getExecutableCodeRefSource which is called internally within the same module. Next Steps:

  • Refactor to accept function as a parameter
  • OR delete when migrating to external dynamic-plugin-sdk

3. import-submit-utils.spec.ts - 2 tests skipped

Reason: Jest 30 no longer supports mocking modules using jest.spyOn. The file is too large to easily refactor for jest.mock. Next Steps:

  • Refactor import-submit-utils.ts into smaller modules that can be mocked
  • Use dependency injection pattern for createOrUpdateDeployment

4. upload-jar-submit-utils.spec.ts - 2 tests skipped

Reason: Same as above - large file that can't be mocked with jest.spyOn in Jest 30. Next Steps:

  • Refactor upload-jar-submit-utils.ts into smaller modules
  • Use dependency injection pattern

Migration Note

The majority of console-dynamic-plugin-sdk code is scheduled for migration to https://github.com/openshift/dynamic-plugin-sdk/. The following modules will be replaced:

  • coderefs/ - CodeRef resolution
  • runtime/ - Plugin loading, manifest validation
  • webpack/ - ConsoleRemotePlugin

The affected unit tests will be removed when that migration is complete.

๐Ÿค– Generated with Claude Code

logonoff avatar Dec 07 '25 05:12 logonoff

@logonoff: This pull request references ODC-6675 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the sub-task to target the "4.21.0" version, but no target version was set.

In response to this:

Summary

  • Upgrade Jest from version 22.4.3 to 30.2.0
  • Update all test configurations for Jest 30 compatibility
  • Fix ES module mocking issues with jest.mock pattern changes
  • Use consistent jest.mock pattern with implicit return throughout codebase

Key Changes

  • Replace jest.spyOn with jest.mock for ES module exports (Jest 30 limitation)
  • Update transformIgnorePatterns to include ESM modules (jsonpath-plus, nanoid, @rjsf)
  • Fix jest.fn<Type>() syntax - remove type parameters (unsupported in Jest 30)
  • Change toBeCalled() to toHaveBeenCalled() (deprecated)
  • Use legacy fake timers for timer-dependent tests
  • Add node-fetch polyfill in before-tests.js for nock v11 compatibility with jsdom

Skipped Tests Added in This PR

1. plugin-loader.spec.ts - describe.skip('loadAndEnablePlugin')

Reason: ES module mocking limitation. loadAndEnablePlugin internally calls loadDynamicPlugin within the same module. With ES modules, internal function calls bypass the mock. Next Steps:

  • Refactor production code to use dependency injection
  • OR delete when migrating to https://github.com/openshift/dynamic-plugin-sdk/

2. active-plugins.spec.ts - 2 tests skipped with it.skip

Reason: These tests mock getExecutableCodeRefSource which is called internally within the same module. Next Steps:

  • Refactor to accept function as a parameter
  • OR delete when migrating to external dynamic-plugin-sdk

3. import-submit-utils.spec.ts - 2 tests skipped with xit

Reason: Jest 30 no longer supports mocking modules using jest.spyOn. The file is too large to easily refactor for jest.mock. Next Steps:

  • Refactor import-submit-utils.ts into smaller modules that can be mocked
  • Use dependency injection pattern for createOrUpdateDeployment

4. upload-jar-submit-utils.spec.ts - 2 tests skipped with xit

Reason: Same as above - large file that can't be mocked with jest.spyOn in Jest 30. Next Steps:

  • Refactor upload-jar-submit-utils.ts into smaller modules
  • Use dependency injection pattern

Pre-existing Skipped Tests (Not from this PR)

File Tests Reason
perspectives.spec.ts 2 xit Needs to load console-extensions.json
ImagesSection.spec.tsx 1 xit Flaky test under investigation
firehose.spec.tsx 2 it.skip Crash issue

Migration Note

The majority of console-dynamic-plugin-sdk code is scheduled for migration to https://github.com/openshift/dynamic-plugin-sdk/. The following modules will be replaced:

  • coderefs/ - CodeRef resolution
  • runtime/ - Plugin loading, manifest validation
  • webpack/ - ConsoleRemotePlugin

The affected unit tests will be removed when that migration is complete.

Test plan

  • [ ] yarn build passes
  • [ ] yarn test passes
  • [ ] Verify no regressions in development mode

๐Ÿค– Generated with Claude Code

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

openshift-ci-robot avatar Dec 07 '25 05:12 openshift-ci-robot

Walkthrough

Adds SWC-based TS/JSX configuration and a GraphQL Jest transformer, migrates Jest testing from ts-jest/Jasmine to modern SWC/Jest patterns, removes several legacy test bootstrap files and typings, centralizes and types many test mocks, and introduces a new exported hook usePipelineAccessReview.

Changes

Cohort / File(s) Summary
SWC & GraphQL transform
frontend/.swcrc, frontend/scripts/jest-transform-graphql.js
Add SWC config (TS/TSX, decorators, automatic React runtime, ES2021 target, minify, sourceMaps) and a Jest GraphQL transformer module exporting process(src).
Jest config & package manifest
frontend/package.json, frontend/jest-resolver.js
Replace ts-jest with SWC-based transforms; update Jest settings (testEnvironment, transform, transformIgnorePatterns, setupFilesAfterEnv, testEnvironmentOptions); remove custom resolver entry and adjust dependencies/resolutions.
Test bootstrap & fetch mock
frontend/before-tests.js, frontend/__mocks__/fetch.ts
Remove prior polyfill/shim bootstrap file; add module mock to set window.fetch using node-fetch.
Type declaration cleanup
frontend/@types/console/index.d.ts, frontend/@types/console/jest.d.ts
Remove ambient reference to Jest typings and delete Jest global augmentation file.
Removed Jest-specific config / lint
frontend/tsconfig-jest.json, frontend/.eslintrc.js
Delete Jest-specific tsconfig; remove jasmine from ESLint env.
Test utilities updates
frontend/packages/console-dynamic-plugin-sdk/src/utils/test-utils.ts, frontend/public/components/cluster-settings/__tests__/test-utils.ts
Change CodeRef/entry-module mock signatures and shapes; expand FileReader mock to full FileReader-like implementation.
New hook & BuildOptions refactor
frontend/packages/dev-console/src/components/import/section/build-section/usePipelineAccessReview.ts, .../BuildOptions.tsx, .../BuildOptions.spec.tsx
Extract previously in-file usePipelineAccessReview into a new exported hook; update BuildOptions to import it and adjust tests.
Mass test modernization (many files)
frontend/packages/**/__tests__/*, frontend/public/**/__tests__/* (see raw summary)
Migrate tests from Jasmine โ†’ Jest: replace spies with jest.mock/jest.fn/jest.spyOn, add typed jest.fn<..., []>() generics, move to module-level mocks, switch reset/restore patterns to clearAllMocks/restoreAllMocks, convert done callbacks to async/await, use legacyFakeTimers where needed, normalize router/location shapes, mark ESM-incompatible tests as xit.
K8s / plugin / dynamic-plugin-sdk test changes
assorted test files under frontend/packages/console-dynamic-plugin-sdk, dev-console, topology, knative-plugin, operator-lifecycle-manager
Centralize module-level mocks for k8s ops and dynamic-plugin APIs, expose typed mock aliases, add RemoteEntryModule casts, and adapt plugin/manifest loader tests for ESM mocking constraints.
Mock typing, assertions & small test fixes
assorted test files (useFlag mocks, matcher updates, timer changes, co-fetch type casts, location hash/key fields)
Standardize mock generic signatures, update assertions to Jest matcher names, use legacyFakeTimers where required, add explicit Response casts, and normalize mocked location objects.

Estimated code review effort

๐ŸŽฏ 4 (Complex) | โฑ๏ธ ~75 minutes

Areas to focus review on:

  • frontend/package.json โ€” SWC/Jest transform entries, transformIgnorePatterns, dependency/resolution changes.
  • frontend/scripts/jest-transform-graphql.js โ€” transformer correctness and compatibility with Jest.
  • frontend/packages/console-dynamic-plugin-sdk/src/utils/test-utils.ts โ€” changed mock APIs and returned mock shapes.
  • New hook usePipelineAccessReview.ts โ€” access-review calls and namespace handling.
  • High-volume test migrations โ€” ensure consistent mock lifecycle (clear/restore), removal of Jasmine idioms, correct use of legacyFakeTimers, and review tests marked xit for ESM issues.
โœจ Finishing touches
  • [ ] ๐Ÿ“ Generate docstrings
๐Ÿงช Generate unit tests (beta)
  • [ ] Create PR with unit tests
  • [ ] Post copyable unit tests in a comment

Comment @coderabbitai help to get the list of available commands and usage tips.

coderabbitai[bot] avatar Dec 07 '25 05:12 coderabbitai[bot]

@logonoff: This pull request references CONSOLE-4970 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.21.0" version, but no target version was set.

In response to this:

Summary

  • Upgrade Jest from version 22.4.3 to 30.2.0
  • Update all test configurations for Jest 30 compatibility
  • Fix ES module mocking issues with jest.mock pattern changes
  • Use consistent jest.mock pattern with implicit return throughout codebase

Key Changes

  • Replace jest.spyOn with jest.mock for ES module exports (Jest 30 limitation)
  • Update transformIgnorePatterns to include ESM modules (jsonpath-plus, nanoid, @rjsf)
  • Fix jest.fn<Type>() syntax - remove type parameters (unsupported in Jest 30)
  • Change toBeCalled() to toHaveBeenCalled() (deprecated)
  • Use legacy fake timers for timer-dependent tests
  • Add node-fetch polyfill in before-tests.js for nock v11 compatibility with jsdom

Skipped Tests Added in This PR

1. plugin-loader.spec.ts - describe.skip('loadAndEnablePlugin')

Reason: ES module mocking limitation. loadAndEnablePlugin internally calls loadDynamicPlugin within the same module. With ES modules, internal function calls bypass the mock. Next Steps:

  • Refactor production code to use dependency injection
  • OR delete when migrating to https://github.com/openshift/dynamic-plugin-sdk/

2. active-plugins.spec.ts - 2 tests skipped with it.skip

Reason: These tests mock getExecutableCodeRefSource which is called internally within the same module. Next Steps:

  • Refactor to accept function as a parameter
  • OR delete when migrating to external dynamic-plugin-sdk

3. import-submit-utils.spec.ts - 2 tests skipped with xit

Reason: Jest 30 no longer supports mocking modules using jest.spyOn. The file is too large to easily refactor for jest.mock. Next Steps:

  • Refactor import-submit-utils.ts into smaller modules that can be mocked
  • Use dependency injection pattern for createOrUpdateDeployment

4. upload-jar-submit-utils.spec.ts - 2 tests skipped with xit

Reason: Same as above - large file that can't be mocked with jest.spyOn in Jest 30. Next Steps:

  • Refactor upload-jar-submit-utils.ts into smaller modules
  • Use dependency injection pattern

Pre-existing Skipped Tests (Not from this PR)

File Tests Reason
perspectives.spec.ts 2 xit Needs to load console-extensions.json
ImagesSection.spec.tsx 1 xit Flaky test under investigation
firehose.spec.tsx 2 it.skip Crash issue

Migration Note

The majority of console-dynamic-plugin-sdk code is scheduled for migration to https://github.com/openshift/dynamic-plugin-sdk/. The following modules will be replaced:

  • coderefs/ - CodeRef resolution
  • runtime/ - Plugin loading, manifest validation
  • webpack/ - ConsoleRemotePlugin

The affected unit tests will be removed when that migration is complete.

Test plan

  • [ ] yarn build passes
  • [ ] yarn test passes
  • [ ] Verify no regressions in development mode

๐Ÿค– Generated with Claude Code

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

openshift-ci-robot avatar Dec 08 '25 15:12 openshift-ci-robot

/label px-approved /label docs-approved

logonoff avatar Dec 08 '25 15:12 logonoff

@logonoff: This pull request references CONSOLE-4970 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.21.0" version, but no target version was set.

In response to this:

Summary

  • Upgrade Jest from version 22.4.3 to 30.2.0
  • Update all test configurations for Jest 30 compatibility
  • Fix ES module mocking issues with jest.mock pattern changes
  • Switched to @swc/jest to increase unit test execution speed

Key Changes

  • Replace jest.spyOn with jest.mock for ES module exports
  • Update transformIgnorePatterns to include ESM modules (jsonpath-plus, nanoid, @rjsf)
  • Updated jest.fn<Type>() syntax to use new type parameters
  • Change toBeCalled() to toHaveBeenCalled() (deprecated)
  • Add node-fetch polyfill in before-tests.js for nock v11 compatibility with jsdom

Skipped Tests Added in This PR

1. plugin-loader.spec.ts - describe.skip('loadAndEnablePlugin')

Reason: ES module mocking limitation. loadAndEnablePlugin internally calls loadDynamicPlugin within the same module. With ES modules, internal function calls bypass the mock. Next Steps:

  • Refactor production code to use dependency injection
  • OR delete when migrating to https://github.com/openshift/dynamic-plugin-sdk/

2. active-plugins.spec.ts - 2 tests skipped with it.skip

Reason: These tests mock getExecutableCodeRefSource which is called internally within the same module. Next Steps:

  • Refactor to accept function as a parameter
  • OR delete when migrating to external dynamic-plugin-sdk

3. import-submit-utils.spec.ts - 2 tests skipped with xit

Reason: Jest 30 no longer supports mocking modules using jest.spyOn. The file is too large to easily refactor for jest.mock. Next Steps:

  • Refactor import-submit-utils.ts into smaller modules that can be mocked
  • Use dependency injection pattern for createOrUpdateDeployment

4. upload-jar-submit-utils.spec.ts - 2 tests skipped with xit

Reason: Same as above - large file that can't be mocked with jest.spyOn in Jest 30. Next Steps:

  • Refactor upload-jar-submit-utils.ts into smaller modules
  • Use dependency injection pattern

Migration Note

The majority of console-dynamic-plugin-sdk code is scheduled for migration to https://github.com/openshift/dynamic-plugin-sdk/. The following modules will be replaced:

  • coderefs/ - CodeRef resolution
  • runtime/ - Plugin loading, manifest validation
  • webpack/ - ConsoleRemotePlugin

The affected unit tests will be removed when that migration is complete.

๐Ÿค– Generated with Claude Code

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

openshift-ci-robot avatar Dec 11 '25 15:12 openshift-ci-robot

@logonoff: This pull request references CONSOLE-4970 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.22.0" version, but no target version was set.

In response to this:

Summary

  • Upgrade Jest from version 22.4.3 to 30.2.0
  • Update all test configurations for Jest 30 compatibility
  • Fix ES module mocking issues with jest.mock pattern changes
  • Switched to @swc/jest to increase unit test execution speed

Key Changes

  • Replace jest.spyOn with jest.mock for ES module exports
  • Update transformIgnorePatterns to include ESM modules (jsonpath-plus, nanoid, @rjsf)
  • Updated jest.fn<Type>() syntax to use new type parameters
  • Change toBeCalled() to toHaveBeenCalled() (deprecated)
  • Add node-fetch polyfill in before-tests.js for nock v11 compatibility with jsdom

Skipped Tests Added in This PR

1. plugin-loader.spec.ts - describe.skip('loadAndEnablePlugin')

Reason: ES module mocking limitation. loadAndEnablePlugin internally calls loadDynamicPlugin within the same module. With ES modules, internal function calls bypass the mock. Next Steps:

  • Refactor production code to use dependency injection
  • OR delete when migrating to https://github.com/openshift/dynamic-plugin-sdk/

2. active-plugins.spec.ts - 2 tests skipped

Reason: These tests mock getExecutableCodeRefSource which is called internally within the same module. Next Steps:

  • Refactor to accept function as a parameter
  • OR delete when migrating to external dynamic-plugin-sdk

3. import-submit-utils.spec.ts - 2 tests skipped

Reason: Jest 30 no longer supports mocking modules using jest.spyOn. The file is too large to easily refactor for jest.mock. Next Steps:

  • Refactor import-submit-utils.ts into smaller modules that can be mocked
  • Use dependency injection pattern for createOrUpdateDeployment

4. upload-jar-submit-utils.spec.ts - 2 tests skipped

Reason: Same as above - large file that can't be mocked with jest.spyOn in Jest 30. Next Steps:

  • Refactor upload-jar-submit-utils.ts into smaller modules
  • Use dependency injection pattern

Migration Note

The majority of console-dynamic-plugin-sdk code is scheduled for migration to https://github.com/openshift/dynamic-plugin-sdk/. The following modules will be replaced:

  • coderefs/ - CodeRef resolution
  • runtime/ - Plugin loading, manifest validation
  • webpack/ - ConsoleRemotePlugin

The affected unit tests will be removed when that migration is complete.

๐Ÿค– Generated with Claude Code

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

openshift-ci-robot avatar Dec 16 '25 23:12 openshift-ci-robot

@logonoff: This pull request references CONSOLE-4970 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.22.0" version, but no target version was set.

In response to this:

Summary

  • Upgrade Jest from version 22.4.3 to 30.2.0
  • Update all test configurations for Jest 30 compatibility
  • Fix ES module mocking issues with jest.mock pattern changes
  • Switched to @swc/jest to increase unit test execution speed (See https://github.com/openshift/console/pull/13986 -- with ts-jest, our unit test dramatically slows down after the jest bump)

Key Changes

  • Replace jest.spyOn with jest.mock for ES module exports
  • Update transformIgnorePatterns to include ESM modules (jsonpath-plus, nanoid, @rjsf)
  • Updated jest.fn<Type>() syntax to use new type parameters
  • Change toBeCalled() to toHaveBeenCalled() (deprecated)
  • Add node-fetch polyfill in before-tests.js for nock v11 compatibility with jsdom

Skipped Tests Added in This PR

1. plugin-loader.spec.ts - describe.skip('loadAndEnablePlugin')

Reason: ES module mocking limitation. loadAndEnablePlugin internally calls loadDynamicPlugin within the same module. With ES modules, internal function calls bypass the mock. Next Steps:

  • Refactor production code to use dependency injection
  • OR delete when migrating to https://github.com/openshift/dynamic-plugin-sdk/

2. active-plugins.spec.ts - 2 tests skipped

Reason: These tests mock getExecutableCodeRefSource which is called internally within the same module. Next Steps:

  • Refactor to accept function as a parameter
  • OR delete when migrating to external dynamic-plugin-sdk

3. import-submit-utils.spec.ts - 2 tests skipped

Reason: Jest 30 no longer supports mocking modules using jest.spyOn. The file is too large to easily refactor for jest.mock. Next Steps:

  • Refactor import-submit-utils.ts into smaller modules that can be mocked
  • Use dependency injection pattern for createOrUpdateDeployment

4. upload-jar-submit-utils.spec.ts - 2 tests skipped

Reason: Same as above - large file that can't be mocked with jest.spyOn in Jest 30. Next Steps:

  • Refactor upload-jar-submit-utils.ts into smaller modules
  • Use dependency injection pattern

Migration Note

The majority of console-dynamic-plugin-sdk code is scheduled for migration to https://github.com/openshift/dynamic-plugin-sdk/. The following modules will be replaced:

  • coderefs/ - CodeRef resolution
  • runtime/ - Plugin loading, manifest validation
  • webpack/ - ConsoleRemotePlugin

The affected unit tests will be removed when that migration is complete.

๐Ÿค– Generated with Claude Code

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

openshift-ci-robot avatar Dec 17 '25 00:12 openshift-ci-robot

@logonoff: This pull request references CONSOLE-4970 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.22.0" version, but no target version was set.

In response to this:

Summary

  • Upgrade Jest from version 22.4.3 to 30.2.0
  • Update all test configurations for Jest 30 compatibility
  • Fix ES module mocking issues with jest.mock pattern changes
  • Switched to @swc/jest to increase unit test execution speed (See https://github.com/openshift/console/pull/13986 -- with ts-jest, our unit test dramatically slows down after the jest bump)

Key Changes

  • Replace jest.spyOn with jest.mock for ES module exports
  • Update transformIgnorePatterns to include ESM modules (jsonpath-plus, nanoid, @rjsf)
  • Updated jest.fn<Type>() syntax to use new type parameters
  • Change toBeCalled() to toHaveBeenCalled() (deprecated)
  • Keep node-fetch polyfill in before-tests.js for nock v11 compatibility with jsdom

Skipped Tests Added in This PR

1. plugin-loader.spec.ts - describe.skip('loadAndEnablePlugin')

Reason: ES module mocking limitation. loadAndEnablePlugin internally calls loadDynamicPlugin within the same module. With ES modules, internal function calls bypass the mock. Next Steps:

  • Refactor production code to use dependency injection
  • OR delete when migrating to https://github.com/openshift/dynamic-plugin-sdk/

2. active-plugins.spec.ts - 2 tests skipped

Reason: These tests mock getExecutableCodeRefSource which is called internally within the same module. Next Steps:

  • Refactor to accept function as a parameter
  • OR delete when migrating to external dynamic-plugin-sdk

3. import-submit-utils.spec.ts - 2 tests skipped

Reason: Jest 30 no longer supports mocking modules using jest.spyOn. The file is too large to easily refactor for jest.mock. Next Steps:

  • Refactor import-submit-utils.ts into smaller modules that can be mocked
  • Use dependency injection pattern for createOrUpdateDeployment

4. upload-jar-submit-utils.spec.ts - 2 tests skipped

Reason: Same as above - large file that can't be mocked with jest.spyOn in Jest 30. Next Steps:

  • Refactor upload-jar-submit-utils.ts into smaller modules
  • Use dependency injection pattern

Migration Note

The majority of console-dynamic-plugin-sdk code is scheduled for migration to https://github.com/openshift/dynamic-plugin-sdk/. The following modules will be replaced:

  • coderefs/ - CodeRef resolution
  • runtime/ - Plugin loading, manifest validation
  • webpack/ - ConsoleRemotePlugin

The affected unit tests will be removed when that migration is complete.

๐Ÿค– Generated with Claude Code

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

openshift-ci-robot avatar Dec 17 '25 00:12 openshift-ci-robot

@logonoff: This pull request references CONSOLE-4970 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.22.0" version, but no target version was set.

In response to this:

Summary

  • Upgrade Jest from version 22.4.3 to 30.2.0
  • Update all test configurations for Jest 30 compatibility
  • Fix ES module mocking issues with jest.mock pattern changes
  • Switched to @swc/jest to increase unit test execution speed. This gives us ~3.7x speedup compared to our existing test suite (See https://github.com/openshift/console/pull/13986 -- with ts-jest, the test suite becomes unreasonably slow after the jest bump)

Key Changes

  • Replace jest.spyOn with jest.mock for ES module exports
  • Update transformIgnorePatterns to include ESM modules (jsonpath-plus, nanoid, @rjsf)
  • Updated jest.fn<Type>() syntax to use new type parameters
  • Change toBeCalled() to toHaveBeenCalled() (deprecated)
  • Keep node-fetch polyfill in before-tests.js for nock v11 compatibility with jsdom

Skipped Tests Added in This PR

1. plugin-loader.spec.ts - describe.skip('loadAndEnablePlugin')

Reason: ES module mocking limitation. loadAndEnablePlugin internally calls loadDynamicPlugin within the same module. With ES modules, internal function calls bypass the mock. Next Steps:

  • Refactor production code to use dependency injection
  • OR delete when migrating to https://github.com/openshift/dynamic-plugin-sdk/

2. active-plugins.spec.ts - 2 tests skipped

Reason: These tests mock getExecutableCodeRefSource which is called internally within the same module. Next Steps:

  • Refactor to accept function as a parameter
  • OR delete when migrating to external dynamic-plugin-sdk

3. import-submit-utils.spec.ts - 2 tests skipped

Reason: Jest 30 no longer supports mocking modules using jest.spyOn. The file is too large to easily refactor for jest.mock. Next Steps:

  • Refactor import-submit-utils.ts into smaller modules that can be mocked
  • Use dependency injection pattern for createOrUpdateDeployment

4. upload-jar-submit-utils.spec.ts - 2 tests skipped

Reason: Same as above - large file that can't be mocked with jest.spyOn in Jest 30. Next Steps:

  • Refactor upload-jar-submit-utils.ts into smaller modules
  • Use dependency injection pattern

Migration Note

The majority of console-dynamic-plugin-sdk code is scheduled for migration to https://github.com/openshift/dynamic-plugin-sdk/. The following modules will be replaced:

  • coderefs/ - CodeRef resolution
  • runtime/ - Plugin loading, manifest validation
  • webpack/ - ConsoleRemotePlugin

The affected unit tests will be removed when that migration is complete.

๐Ÿค– Generated with Claude Code

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

openshift-ci-robot avatar Dec 17 '25 03:12 openshift-ci-robot

/assign @yapei

logonoff avatar Dec 18 '25 02:12 logonoff

test only changes

/verified by CI

logonoff avatar Dec 18 '25 15:12 logonoff

@logonoff: This PR has been marked as verified by CI.

In response to this:

test only changes

/verified by CI

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

openshift-ci-robot avatar Dec 18 '25 15:12 openshift-ci-robot

/lgtm

cajieh avatar Dec 18 '25 18:12 cajieh

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: cajieh, logonoff

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment Approvers can cancel approval by writing /approve cancel in a comment

openshift-ci[bot] avatar Dec 18 '25 18:12 openshift-ci[bot]