Skip to content

Commit e51f771

Browse files
lbogdanCompuIves
authored andcommitted
Integration tests: use waitUntil: 'networkidle0' instead of waiting for element. (codesandbox#357)
1 parent c3aa2d6 commit e51f771

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

packages/app/integration-tests/tests/sandboxes.test.js

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import puppeteer from 'puppeteer';
33
const SANDBOXES = [
44
'new',
55
'preact',
6-
{ id: 'vue', root: '#app' },
6+
'vue',
77
'svelte',
88
'react-ts',
99
'github/reactjs/redux/tree/master/examples/todomvc',
@@ -12,19 +12,17 @@ const SANDBOXES = [
1212
'github/faceyspacey/redux-first-router-codesandbox/tree/master',
1313
'mZRjw05yp',
1414
'pk1qjqpw67',
15-
{ id: 'o29j95wx9', root: '#app' },
16-
{ id: 'k3q1zjjml5', root: '#app' },
15+
'o29j95wx9',
16+
'k3q1zjjml5',
1717
'github/reactjs/redux/tree/master/examples/real-world',
18-
{ id: 'github/CompuIves/codesandbox-presentation', timeout: 60000 },
18+
'github/CompuIves/codesandbox-presentation',
1919
'lp5rjr0z4z',
2020
'nOymMxyY',
2121
];
2222

2323
SANDBOXES.forEach(sandbox => {
2424
const id = sandbox.id || sandbox;
25-
const root = sandbox.root || '#root';
2625
const threshold = sandbox.threshold || 0.01;
27-
const timeout = sandbox.timeout || 30000;
2826
let browser = puppeteer.launch({
2927
args: ['--no-sandbox', '--disable-setuid-sandbox'],
3028
});
@@ -39,13 +37,11 @@ SANDBOXES.forEach(sandbox => {
3937
async () => {
4038
browser = await browser;
4139
const page = await browser.newPage();
42-
await page.goto('http://localhost:3001/#' + id);
43-
await page.waitForSelector(root, { timeout });
40+
await page.goto('http://localhost:3001/#' + id, {
41+
waitUntil: 'networkidle0',
42+
});
4443
await page.waitFor(2000);
4544

46-
// const html = await page.evaluate(() => document.body.innerHTML);
47-
// expect(html).toMatchSnapshot(id.split('/').join('-'));
48-
4945
const screenshot = await page.screenshot();
5046

5147
expect(screenshot).toMatchImageSnapshot({

0 commit comments

Comments
 (0)