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:
Norbert de Langen 2017-10-31 21:39:06 +01:00 committed by GitHub
commit aebe01f007
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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('-'),
});
});
});
});