Skip to content

Commit 68cac4d

Browse files
ravikiranvmdependabot[bot]claudeMarceloRGonc
authored
Upgrade Jest from 29 to 30 (#2491)
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: - [x] I tested the feature thoroughly, including edge cases - [x] I verified all affected areas still work as expected - [x] Automated tests were added/updated if necessary - [x] 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](https://claude.com/claude-code) --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com> Co-authored-by: Marcelo Gonçalves <marcelo@openops.com>
1 parent 00a7bb6 commit 68cac4d

29 files changed

Lines changed: 19565 additions & 24809 deletions

package-lock.json

Lines changed: 19379 additions & 24633 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@
338338
"@types/color": "3.0.7",
339339
"@types/contrast-color": "1.0.3",
340340
"@types/is-base64": "1.1.3",
341-
"@types/jest": "29.5.14",
341+
"@types/jest": "30.0.0",
342342
"@types/lodash-es": "4.17.12",
343343
"@types/lodash.debounce": "4.0.9",
344344
"@types/lru-cache": "7.10.10",
@@ -367,7 +367,7 @@
367367
"@vitest/eslint-plugin": "1.6.27",
368368
"@vitest/ui": "1.6.1",
369369
"autoprefixer": "10.5.0",
370-
"babel-jest": "29.7.0",
370+
"babel-jest": "30.4.1",
371371
"cd": "0.3.3",
372372
"chromatic": "11.29.0",
373373
"concurrently": "8.2.2",
@@ -390,9 +390,9 @@
390390
"husky": "9.1.7",
391391
"i18next-cli": "1.64.1",
392392
"inquirer": "8.2.7",
393-
"jest": "29.7.0",
394-
"jest-environment-jsdom": "29.7.0",
395-
"jest-environment-node": "29.7.0",
393+
"jest": "30.4.2",
394+
"jest-environment-jsdom": "30.4.1",
395+
"jest-environment-node": "30.4.1",
396396
"jsonc-eslint-parser": "3.3.0",
397397
"lint-staged": "15.5.2",
398398
"nx-cloud": "19.1.3",
@@ -405,7 +405,7 @@
405405
"prettier-plugin-organize-imports": "4.3.0",
406406
"storybook": "10.6.0",
407407
"tailwindcss": "3.4.19",
408-
"ts-jest": "29.4.11",
408+
"ts-jest": "29.4.12",
409409
"ts-node": "10.9.2",
410410
"typescript": "5.5.4",
411411
"typescript-eslint": "8.66.0",

packages/blocks/anodot/test/common/recommendations.test.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ describe('getAnodotRecommendations', () => {
4343
);
4444

4545
expect(result).toEqual(['some info']);
46-
expect(makeHttpRequestMock).toBeCalledTimes(1);
46+
expect(makeHttpRequestMock).toHaveBeenCalledTimes(1);
4747
expect(makeHttpRequestMock).toHaveBeenCalledWith(
4848
'POST',
4949
'apiUrl/v2/recommendations/list',
@@ -54,7 +54,7 @@ describe('getAnodotRecommendations', () => {
5454
sort: [{ by: 'savings', order: 'desc' }],
5555
},
5656
);
57-
expect(createAnodotAuthHeadersMock).toBeCalledTimes(1);
57+
expect(createAnodotAuthHeadersMock).toHaveBeenCalledTimes(1);
5858
expect(createAnodotAuthHeadersMock).toHaveBeenCalledWith(
5959
'authToken',
6060
'accountApiKey',
@@ -71,7 +71,7 @@ describe('getAnodotRecommendations', () => {
7171
).rejects.toThrow('some error');
7272

7373
expect(makeHttpRequestMock).not.toHaveBeenCalled();
74-
expect(createAnodotAuthHeadersMock).toBeCalledTimes(1);
74+
expect(createAnodotAuthHeadersMock).toHaveBeenCalledTimes(1);
7575
expect(createAnodotAuthHeadersMock).toHaveBeenCalledWith(
7676
'authToken',
7777
'accountApiKey',
@@ -109,7 +109,7 @@ describe('getAnodotRecommendations', () => {
109109
'some recommendation 3',
110110
'some recommendation 4',
111111
]);
112-
expect(makeHttpRequestMock).toBeCalledTimes(3);
112+
expect(makeHttpRequestMock).toHaveBeenCalledTimes(3);
113113
expect(makeHttpRequestMock).toHaveBeenNthCalledWith(
114114
1,
115115
'POST',
@@ -145,7 +145,7 @@ describe('getAnodotRecommendations', () => {
145145
sort: [{ by: 'savings', order: 'desc' }],
146146
},
147147
);
148-
expect(createAnodotAuthHeadersMock).toBeCalledTimes(1);
148+
expect(createAnodotAuthHeadersMock).toHaveBeenCalledTimes(1);
149149
expect(createAnodotAuthHeadersMock).toHaveBeenCalledWith(
150150
'authToken',
151151
'accountApiKey',
@@ -177,7 +177,7 @@ describe('setUserStatusForRecommendation', () => {
177177
);
178178

179179
expect(result).toEqual('mock result');
180-
expect(makeHttpRequestMock).toBeCalledTimes(1);
180+
expect(makeHttpRequestMock).toHaveBeenCalledTimes(1);
181181
expect(makeHttpRequestMock).toHaveBeenCalledWith(
182182
'POST',
183183
'apiUrl/v2/recommendations/user-action',
@@ -193,7 +193,7 @@ describe('setUserStatusForRecommendation', () => {
193193
},
194194
},
195195
);
196-
expect(createAnodotAuthHeadersMock).toBeCalledTimes(1);
196+
expect(createAnodotAuthHeadersMock).toHaveBeenCalledTimes(1);
197197
expect(createAnodotAuthHeadersMock).toHaveBeenCalledWith(
198198
'authToken',
199199
'accountApiKey',
@@ -217,7 +217,7 @@ describe('setUserStatusForRecommendation', () => {
217217
).rejects.toThrow('some error');
218218

219219
expect(makeHttpRequestMock).not.toHaveBeenCalled();
220-
expect(createAnodotAuthHeadersMock).toBeCalledTimes(1);
220+
expect(createAnodotAuthHeadersMock).toHaveBeenCalledTimes(1);
221221
expect(createAnodotAuthHeadersMock).toHaveBeenCalledWith(
222222
'authToken',
223223
'accountApiKey',

packages/openops/test/auth.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,6 @@ describe('getRoleForAccount tests', () => {
408408
},
409409
'4',
410410
),
411-
).toThrowError('Role not found for account');
411+
).toThrow('Role not found for account');
412412
});
413413
});

packages/openops/test/aws/ebs/create-ebs-snapshot.test.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ describe('createSnapshot tests', () => {
6363

6464
expect(result).toEqual({ SnapshotId: 'volumeId1', State: 'completed' });
6565
expect(waitForMock.waitForConditionWithTimeout).toHaveBeenCalledTimes(1);
66-
expect(waitForMock.waitForConditionWithTimeout).toBeCalledWith(
66+
expect(waitForMock.waitForConditionWithTimeout).toHaveBeenCalledWith(
6767
expect.any(Function),
6868
300,
6969
2000,
@@ -80,7 +80,7 @@ describe('createSnapshot tests', () => {
8080
SnapshotIds: ['volumeId1'],
8181
DryRun: false,
8282
});
83-
expect(getAwsClientMock.getAwsClient).toBeCalledTimes(1);
83+
expect(getAwsClientMock.getAwsClient).toHaveBeenCalledTimes(1);
8484
});
8585

8686
test('should throw if wait for timeout throws', async () => {
@@ -114,7 +114,7 @@ describe('createSnapshot tests', () => {
114114
dryRun: false,
115115
}),
116116
).rejects.toThrow('Snapshot creation timed out');
117-
expect(getAwsClientMock.getAwsClient).toBeCalledTimes(1);
117+
expect(getAwsClientMock.getAwsClient).toHaveBeenCalledTimes(1);
118118
});
119119

120120
test('should throw when snapshot creation status is error', async () => {
@@ -129,8 +129,8 @@ describe('createSnapshot tests', () => {
129129
dryRun: false,
130130
}),
131131
).rejects.toThrow('Snapshot creation failed with error: mock Error');
132-
expect(getAwsClientMock.getAwsClient).toBeCalledTimes(1);
133-
expect(waitForMock.waitForConditionWithTimeout).not.toBeCalled();
132+
expect(getAwsClientMock.getAwsClient).toHaveBeenCalledTimes(1);
133+
expect(waitForMock.waitForConditionWithTimeout).not.toHaveBeenCalled();
134134
});
135135

136136
test('should throw when describe Snapshot returns with error state', async () => {
@@ -164,7 +164,7 @@ describe('createSnapshot tests', () => {
164164
SnapshotIds: ['volumeId1'],
165165
DryRun: true,
166166
});
167-
expect(getAwsClientMock.getAwsClient).toBeCalledTimes(1);
167+
expect(getAwsClientMock.getAwsClient).toHaveBeenCalledTimes(1);
168168
});
169169

170170
test('should not wait for if no number is provided', async () => {
@@ -187,7 +187,7 @@ describe('createSnapshot tests', () => {
187187
})) as any;
188188
expect(result).toStrictEqual({ SnapshotId: 'volumeId1' });
189189
expect(describeSnapshotMock).not.toHaveBeenCalled();
190-
expect(waitForMock.waitForConditionWithTimeout).not.toBeCalled();
191-
expect(getAwsClientMock.getAwsClient).toBeCalledTimes(1);
190+
expect(waitForMock.waitForConditionWithTimeout).not.toHaveBeenCalled();
191+
expect(getAwsClientMock.getAwsClient).toHaveBeenCalledTimes(1);
192192
});
193193
});

packages/openops/test/aws/ebs/delete-ebs-snapshot.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ describe('deleteSnapshot tests', () => {
6565
message: 'Snapshot deleted',
6666
});
6767
expect(waitForMock.waitForConditionWithTimeout).toHaveBeenCalledTimes(1);
68-
expect(waitForMock.waitForConditionWithTimeout).toBeCalledWith(
68+
expect(waitForMock.waitForConditionWithTimeout).toHaveBeenCalledWith(
6969
expect.any(Function),
7070
300,
7171
2000,
@@ -81,7 +81,7 @@ describe('deleteSnapshot tests', () => {
8181
SnapshotIds: ['volumeId1'],
8282
DryRun: false,
8383
});
84-
expect(getAwsClientMock.getAwsClient).toBeCalledTimes(1);
84+
expect(getAwsClientMock.getAwsClient).toHaveBeenCalledTimes(1);
8585
});
8686

8787
test('should throw if wait for timeout throws', async () => {
@@ -116,7 +116,7 @@ describe('deleteSnapshot tests', () => {
116116
await expect(
117117
deleteEbsSnapshot(credentials, 'region1', 'volumeId1', false, 10),
118118
).rejects.toThrow('Snapshot deletion timed out');
119-
expect(getAwsClientMock.getAwsClient).toBeCalledTimes(1);
119+
expect(getAwsClientMock.getAwsClient).toHaveBeenCalledTimes(1);
120120
});
121121

122122
test('should throw when describe Snapshot returns with error state', async () => {
@@ -151,7 +151,7 @@ describe('deleteSnapshot tests', () => {
151151
SnapshotIds: ['volumeId1'],
152152
DryRun: true,
153153
});
154-
expect(getAwsClientMock.getAwsClient).toBeCalledTimes(1);
154+
expect(getAwsClientMock.getAwsClient).toHaveBeenCalledTimes(1);
155155
});
156156

157157
test('should not wait for if no number is provided', async () => {
@@ -184,7 +184,7 @@ describe('deleteSnapshot tests', () => {
184184
snapshotId: 'volumeId1',
185185
});
186186
expect(describeSnapshotMock).not.toHaveBeenCalled();
187-
expect(waitForMock.waitForConditionWithTimeout).not.toBeCalled();
188-
expect(getAwsClientMock.getAwsClient).toBeCalledTimes(1);
187+
expect(waitForMock.waitForConditionWithTimeout).not.toHaveBeenCalled();
188+
expect(getAwsClientMock.getAwsClient).toHaveBeenCalledTimes(1);
189189
});
190190
});

packages/openops/test/aws/ebs/delete-ebs-volume.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ describe('delete ebs volume tests', () => {
3333
);
3434
expect(result).toEqual({});
3535

36-
expect(getAwsClientMock.getAwsClient).toBeCalledTimes(1);
37-
expect(deleteVolumeMock).toBeCalledWith(
36+
expect(getAwsClientMock.getAwsClient).toHaveBeenCalledTimes(1);
37+
expect(deleteVolumeMock).toHaveBeenCalledWith(
3838
expect.objectContaining({ DryRun: false, VolumeId: 'volume1' }),
3939
);
4040
});
@@ -46,7 +46,7 @@ describe('delete ebs volume tests', () => {
4646

4747
await deleteEbsVolume(credentials, 'region1', 'volume1', dryRun);
4848

49-
expect(deleteVolumeMock).toBeCalledWith(
49+
expect(deleteVolumeMock).toHaveBeenCalledWith(
5050
expect.objectContaining({ DryRun: dryRun, VolumeId: 'volume1' }),
5151
);
5252
},

packages/openops/test/aws/ebs/ebs-get-snapshots.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,13 @@ describe('getEbsSnapshots', () => {
4747
filters,
4848
);
4949

50-
expect(getAwsClientMock.getAwsClient).toBeCalledTimes(2);
51-
expect(getAwsClientMock.getAwsClient).toBeCalledWith(
50+
expect(getAwsClientMock.getAwsClient).toHaveBeenCalledTimes(2);
51+
expect(getAwsClientMock.getAwsClient).toHaveBeenCalledWith(
5252
EC2.EC2,
5353
CREDENTIALS,
5454
'some-region1',
5555
);
56-
expect(getAwsClientMock.getAwsClient).toBeCalledWith(
56+
expect(getAwsClientMock.getAwsClient).toHaveBeenCalledWith(
5757
EC2.EC2,
5858
CREDENTIALS,
5959
'some-region2',

packages/openops/test/aws/ebs/ebs-get-volumes.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,13 @@ describe('getEbsVolumes', () => {
5959
filters,
6060
);
6161

62-
expect(getAwsClientMock.getAwsClient).toBeCalledTimes(2);
63-
expect(getAwsClientMock.getAwsClient).toBeCalledWith(
62+
expect(getAwsClientMock.getAwsClient).toHaveBeenCalledTimes(2);
63+
expect(getAwsClientMock.getAwsClient).toHaveBeenCalledWith(
6464
EC2.EC2,
6565
CREDENTIALS,
6666
'some-region1',
6767
);
68-
expect(getAwsClientMock.getAwsClient).toBeCalledWith(
68+
expect(getAwsClientMock.getAwsClient).toHaveBeenCalledWith(
6969
EC2.EC2,
7070
CREDENTIALS,
7171
'some-region2',
@@ -130,8 +130,8 @@ describe('getEbsVolumes', () => {
130130
filters,
131131
);
132132

133-
expect(getAwsClientMock.getAwsClient).toBeCalledTimes(1);
134-
expect(getAwsClientMock.getAwsClient).toBeCalledWith(
133+
expect(getAwsClientMock.getAwsClient).toHaveBeenCalledTimes(1);
134+
expect(getAwsClientMock.getAwsClient).toHaveBeenCalledWith(
135135
EC2.EC2,
136136
CREDENTIALS,
137137
'some-region1',

packages/openops/test/aws/ec2/ec2-get-instances.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,13 @@ describe('getEc2Instances', () => {
7171
false,
7272
filters,
7373
);
74-
expect(getAwsClientMock.getAwsClient).toBeCalledTimes(2);
75-
expect(getAwsClientMock.getAwsClient).toBeCalledWith(
74+
expect(getAwsClientMock.getAwsClient).toHaveBeenCalledTimes(2);
75+
expect(getAwsClientMock.getAwsClient).toHaveBeenCalledWith(
7676
EC2.EC2,
7777
CREDENTIALS,
7878
'some-region1',
7979
);
80-
expect(getAwsClientMock.getAwsClient).toBeCalledWith(
80+
expect(getAwsClientMock.getAwsClient).toHaveBeenCalledWith(
8181
EC2.EC2,
8282
CREDENTIALS,
8383
'some-region2',

0 commit comments

Comments
 (0)