Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IMPROVE integration tests so they all output a diff image when multiple fail #2197

Merged
merged 1 commit into from
Oct 31, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 17 additions & 19 deletions integration/examples.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

const screenshot = await page.screenshot({ fullPage: true });
it(`Take screenshots for '${name}'`, async () => {
await page.goto(`http://localhost:${port}`);
await page.waitForSelector('[role="menuitem"][data-name="Welcome"]');
await page.waitFor(2000);

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