mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-06 07:21:16 +08:00
Merge pull request #2197 from storybooks/ndelangen/improve-integration-tests
IMPROVE integration tests so they all output a diff image when multiple fail
This commit is contained in:
commit
aebe01f007
@ -13,31 +13,29 @@ const examples = [
|
|||||||
|
|
||||||
examples.forEach(({ name, port }) => {
|
examples.forEach(({ name, port }) => {
|
||||||
let browser = puppeteer.launch();
|
let browser = puppeteer.launch();
|
||||||
|
let page;
|
||||||
|
|
||||||
describe('sandboxes', () => {
|
describe('sandboxes', () => {
|
||||||
|
beforeAll(async () => {
|
||||||
|
browser = await browser;
|
||||||
|
page = await browser.newPage();
|
||||||
|
await page.setViewport({ width: 1400, height: 1000 });
|
||||||
|
});
|
||||||
afterAll(() => {
|
afterAll(() => {
|
||||||
browser.close();
|
browser.close();
|
||||||
});
|
});
|
||||||
|
|
||||||
it.concurrent(
|
it(`Take screenshots for '${name}'`, async () => {
|
||||||
`Take screenshots for '${name}'`,
|
await page.goto(`http://localhost:${port}`);
|
||||||
async () => {
|
await page.waitForSelector('[role="menuitem"][data-name="Welcome"]');
|
||||||
browser = await browser;
|
await page.waitFor(2000);
|
||||||
const page = await browser.newPage();
|
|
||||||
await page.setViewport({ width: 1400, height: 1000 });
|
|
||||||
await page.goto(`http://localhost:${port}`);
|
|
||||||
await page.waitForSelector('[role="menuitem"][data-name="Welcome"]');
|
|
||||||
await page.waitFor(2000);
|
|
||||||
|
|
||||||
const screenshot = await page.screenshot({ fullPage: true });
|
const screenshot = await page.screenshot({ fullPage: true });
|
||||||
|
expect(screenshot).toMatchImageSnapshot({
|
||||||
expect(screenshot).toMatchImageSnapshot({
|
failureThreshold: 0.04, // 4% threshold,
|
||||||
failureThreshold: 0.04, // 4% threshold,
|
failureThresholdType: 'percent',
|
||||||
failureThresholdType: 'percent',
|
customSnapshotIdentifier: name.split('/').join('-'),
|
||||||
customSnapshotIdentifier: name.split('/').join('-'),
|
});
|
||||||
});
|
});
|
||||||
},
|
|
||||||
1000 * 60 * 10 // 10 minutes for all tests in total
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user