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 }) => { 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
);
}); });
}); });