mirror of
https://github.com/ant-design/ant-design.git
synced 2025-06-07 17:44:35 +08:00
chore: Improve visual regression screenshot warning (#52053)
* chore: Improve visual regression screenshot warning * chore: update * what?
This commit is contained in:
parent
4fcf3da852
commit
bc28f57977
@ -1,5 +1,7 @@
|
|||||||
import { imageDemoTest } from '../../../tests/shared/imageTest';
|
import { imageDemoTest } from '../../../tests/shared/imageTest';
|
||||||
|
|
||||||
describe('Affix image', () => {
|
describe('Affix image', () => {
|
||||||
imageDemoTest('affix');
|
imageDemoTest('affix', {
|
||||||
|
onlyViewport: ['debug.tsx'],
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@ -8,6 +8,7 @@ import fse from 'fs-extra';
|
|||||||
import { globSync } from 'glob';
|
import { globSync } from 'glob';
|
||||||
import { JSDOM } from 'jsdom';
|
import { JSDOM } from 'jsdom';
|
||||||
import MockDate from 'mockdate';
|
import MockDate from 'mockdate';
|
||||||
|
import rcWarning from 'rc-util/lib/warning';
|
||||||
import type { HTTPRequest } from 'puppeteer';
|
import type { HTTPRequest } from 'puppeteer';
|
||||||
import ReactDOMServer from 'react-dom/server';
|
import ReactDOMServer from 'react-dom/server';
|
||||||
|
|
||||||
@ -202,6 +203,14 @@ export default function imageTest(
|
|||||||
if (!options.onlyViewport) {
|
if (!options.onlyViewport) {
|
||||||
// Get scroll height of the rendered page and set viewport
|
// Get scroll height of the rendered page and set viewport
|
||||||
const bodyHeight = await page.evaluate(() => document.body.scrollHeight);
|
const bodyHeight = await page.evaluate(() => document.body.scrollHeight);
|
||||||
|
|
||||||
|
// loooooong image
|
||||||
|
rcWarning(
|
||||||
|
bodyHeight < 4096, // Expected height
|
||||||
|
`[IMAGE TEST] [${identifier}] may cause screenshots to be very long and unacceptable.
|
||||||
|
Please consider using \`onlyViewport: ["filename.tsx"]\`, read more: https://github.com/ant-design/ant-design/pull/52053`,
|
||||||
|
);
|
||||||
|
|
||||||
await page.setViewport({ width: 800, height: bodyHeight });
|
await page.setViewport({ width: 800, height: bodyHeight });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user