mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-05 16:11:33 +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 }) => {
|
||||
let browser = puppeteer.launch();
|
||||
let page;
|
||||
|
||||
describe('sandboxes', () => {
|
||||
beforeAll(async () => {
|
||||
browser = await browser;
|
||||
page = await browser.newPage();
|
||||
await page.setViewport({ width: 1400, height: 1000 });
|
||||
});
|
||||
afterAll(() => {
|
||||
browser.close();
|
||||
});
|
||||
|
||||
it.concurrent(
|
||||
`Take screenshots for '${name}'`,
|
||||
async () => {
|
||||
browser = await browser;
|
||||
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);
|
||||
it(`Take screenshots for '${name}'`, async () => {
|
||||
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 });
|
||||
|
||||
expect(screenshot).toMatchImageSnapshot({
|
||||
failureThreshold: 0.04, // 4% threshold,
|
||||
failureThresholdType: 'percent',
|
||||
customSnapshotIdentifier: name.split('/').join('-'),
|
||||
});
|
||||
},
|
||||
1000 * 60 * 10 // 10 minutes for all tests in total
|
||||
);
|
||||
const screenshot = await page.screenshot({ fullPage: true });
|
||||
expect(screenshot).toMatchImageSnapshot({
|
||||
failureThreshold: 0.04, // 4% threshold,
|
||||
failureThresholdType: 'percent',
|
||||
customSnapshotIdentifier: name.split('/').join('-'),
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user