Skip to content

Commit 60285bd

Browse files
chore: bump jsdom (ant-design#57016)
* test * test * fix * fix * test --------- Co-authored-by: lijianan <574980606@qq.com>
1 parent 932e435 commit 60285bd

2 files changed

Lines changed: 6 additions & 7 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@
266266
"jest-image-snapshot": "^6.5.1",
267267
"jest-puppeteer": "^11.0.0",
268268
"jquery": "^4.0.0",
269-
"jsdom": "~28.0.0",
269+
"jsdom": "~28.1.0",
270270
"jsonml-to-react-element": "^1.1.11",
271271
"jsonml.js": "^0.1.0",
272272
"lint-staged": "^16.2.7",

tests/setupAfterEnv.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import '@testing-library/jest-dom';
22

33
import { toHaveNoViolations } from 'jest-axe';
4-
import jsdom from 'jsdom';
54
import format, { plugins } from 'pretty-format';
65

76
import { defaultConfig } from '../components/theme/internal';
@@ -90,12 +89,12 @@ expect.addSnapshotSerializer({
9089
test: (node) => node && typeof node === 'object' && node.type === 'demo' && node.html,
9190
// @ts-ignore
9291
print: ({ html }) => {
93-
const { JSDOM } = jsdom;
94-
const { document } = new JSDOM().window;
95-
document.body.innerHTML = html;
92+
// Create a temporary container to parse HTML
93+
const container = document.createElement('div');
94+
container.innerHTML = html;
9695

97-
const children = Array.from(document.body.childNodes).filter(
98-
(node) =>
96+
const children = Array.from(container.childNodes).filter(
97+
(node: any) =>
9998
// Ignore `link` node since React 18 or blew not support this
10099
node.nodeName !== 'LINK',
101100
);

0 commit comments

Comments
 (0)