diff --git a/package.json b/package.json index cc0c319e80..fa8be6ec6c 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/tests/shared/imageTest.tsx b/tests/shared/imageTest.tsx index 2936d2bbb9..76b380f06a 100644 --- a/tests/shared/imageTest.tsx +++ b/tests/shared/imageTest.tsx @@ -42,7 +42,7 @@ export default function imageTest( let container: HTMLDivElement; beforeAll(async () => { - const dom = new JSDOM('

', { + const dom = new JSDOM('', { 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); }); }