mirror of
https://github.com/ant-design/ant-design.git
synced 2026-02-09 02:49:18 +08:00
test: add removeAllListeners for imageTest (#55015)
* test: add try/catch for visual diff * Update tests/shared/imageTest.tsx Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Signed-off-by: lijianan <574980606@qq.com> * update * update * update --------- Signed-off-by: lijianan <574980606@qq.com> Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
This commit is contained in:
@@ -46,9 +46,7 @@ export default function imageTest(
|
||||
let container: HTMLDivElement;
|
||||
|
||||
beforeAll(async () => {
|
||||
const dom = new JSDOM('<!DOCTYPE html><body></body></html>', {
|
||||
url: 'http://localhost/',
|
||||
});
|
||||
const dom = new JSDOM('<!DOCTYPE html><body></body></html>', { url: 'http://localhost/' });
|
||||
const win = dom.window;
|
||||
doc = win.document;
|
||||
|
||||
@@ -112,6 +110,14 @@ export default function imageTest(
|
||||
container = doc.querySelector<HTMLDivElement>('#root')!;
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
page.removeAllListeners('request'); // 保证没有历史残留
|
||||
});
|
||||
|
||||
afterAll(async () => {
|
||||
await page.setRequestInterception(false);
|
||||
});
|
||||
|
||||
const test = (
|
||||
name: string,
|
||||
suffix: string,
|
||||
@@ -234,7 +240,6 @@ export default function imageTest(
|
||||
);
|
||||
await page.setViewport({ width: 800, height: bodyHeight, ...sharedViewportConfig });
|
||||
}
|
||||
|
||||
const image = await page.screenshot({ fullPage: !options.onlyViewport });
|
||||
await fse.writeFile(path.join(snapshotPath, `${identifier}${suffix}.png`), image);
|
||||
MockDate.reset();
|
||||
|
||||
Reference in New Issue
Block a user