Skip to content

Commit 3d866f6

Browse files
authored
chore(global-header): migrate to Jest 30 (#3012)
Install Jest 30 peer dependencies as required by @backstage/cli 0.36.0 and fix test incompatibilities for Jest 30 and JSDOM 27. Signed-off-by: Jon Koops <jonkoops@gmail.com>
1 parent 0db360d commit 3d866f6

7 files changed

Lines changed: 2323 additions & 157 deletions

File tree

workspaces/global-header/package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,12 @@
5050
"@backstage/e2e-test-utils": "^0.1.2",
5151
"@backstage/repo-tools": "^0.17.0",
5252
"@changesets/cli": "^2.27.1",
53+
"@jest/environment-jsdom-abstract": "^30.3.0",
5354
"@playwright/test": "1.58.2",
55+
"@types/jest": "^30.0.0",
56+
"@types/jsdom": "^27.0.0",
57+
"jest": "^30.3.0",
58+
"jsdom": "^27.1.0",
5459
"knip": "^5.27.4",
5560
"node-gyp": "^9.0.0",
5661
"prettier": "^2.3.2",
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* Copyright Red Hat, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
// Node 25+ removed SlowBuffer from the buffer module.
18+
// Transitive deps (buffer-equal-constant-time via jsonwebtoken) still reference it.
19+
const bufferModule = require('node:buffer');
20+
21+
if (!bufferModule.SlowBuffer) {
22+
bufferModule.SlowBuffer = bufferModule.Buffer;
23+
}

workspaces/global-header/packages/app-legacy/package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@
1111
"backstage": {
1212
"role": "frontend"
1313
},
14+
"jest": {
15+
"setupFiles": [
16+
"<rootDir>/../jest.setup.js"
17+
]
18+
},
1419
"scripts": {
1520
"start": "backstage-cli package start",
1621
"build": "backstage-cli package build",
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* Copyright Red Hat, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
// Node 25+ removed SlowBuffer from the buffer module.
18+
// Transitive deps (buffer-equal-constant-time via jsonwebtoken) still reference it.
19+
const bufferModule = require('node:buffer');
20+
21+
if (!bufferModule.SlowBuffer) {
22+
bufferModule.SlowBuffer = bufferModule.Buffer;
23+
}

workspaces/global-header/packages/app/package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@
1111
"backstage": {
1212
"role": "frontend"
1313
},
14+
"jest": {
15+
"setupFiles": [
16+
"<rootDir>/../jest.setup.js"
17+
]
18+
},
1419
"scripts": {
1520
"start": "backstage-cli package start",
1621
"build": "backstage-cli package build",

workspaces/global-header/plugins/global-header/src/components/HeaderDropdownComponent/HelpDropdown.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ describe('HelpDropdown', () => {
297297

298298
const button = screen.getByRole('button');
299299
expect(button).toHaveStyle('margin-left: 16px');
300-
expect(button).toHaveStyle('color: red');
300+
expect(button).toHaveStyle('color: rgb(255, 0, 0)');
301301
});
302302

303303
it('processes mount point configurations correctly', async () => {

0 commit comments

Comments
 (0)