fix: issues in imageTest.tsx (#49826)

* chore(deps): removed deprecated `crypto@1.0.1`

* fix: issues in `imageTest.tsx`
This commit is contained in:
Rubu Jam 2024-07-12 10:28:58 +08:00 committed by GitHub
parent d063f562eb
commit 1d84cca4e3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 5 deletions

View File

@ -222,7 +222,6 @@
"cli-progress": "^3.12.0",
"cross-env": "^7.0.3",
"cross-fetch": "^4.0.0",
"crypto": "^1.0.1",
"dekko": "^0.2.1",
"dotenv": "^16.4.5",
"dumi": "~2.4.0",

View File

@ -42,7 +42,7 @@ export default function imageTest(
let container: HTMLDivElement;
beforeAll(async () => {
const dom = new JSDOM('<!DOCTYPE html><body></body></p>', {
const dom = new JSDOM('<!DOCTYPE html><body></body></html>', {
url: 'http://localhost/',
});
const win = dom.window;
@ -121,8 +121,10 @@ export default function imageTest(
const { openTriggerClassName } = options;
const requestListener = (request: any) => onRequestHandle(request as HTTPRequest);
MockDate.set(dayjs('2016-11-22').valueOf());
page.on('request', onRequestHandle);
page.on('request', requestListener);
await page.goto(`file://${process.cwd()}/tests/index.html`);
await page.addStyleTag({ path: `${process.cwd()}/components/style/reset.css` });
await page.addStyleTag({ content: '*{animation: none!important;}' });
@ -194,7 +196,7 @@ export default function imageTest(
},
html,
styleStr,
openTriggerClassName,
openTriggerClassName || '',
);
if (!options.onlyViewport) {
@ -210,7 +212,7 @@ export default function imageTest(
await fse.writeFile(path.join(snapshotPath, `${identifier}${suffix}.png`), image);
MockDate.reset();
page.off('request', onRequestHandle);
page.off('request', requestListener);
});
}