Skip to content

Commit

Permalink
More stable tests by increasing timeouts and launching a new page on …
Browse files Browse the repository at this point in the history
…each test
  • Loading branch information
youknowriad committed Mar 21, 2018
1 parent 67813ee commit e35fbfa
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 11 deletions.
3 changes: 2 additions & 1 deletion test/e2e/specs/a11y.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
* Internal dependencies
*/
import '../support/bootstrap';
import { newPost } from '../support/utils';
import { newPost, newDesktopBrowserPage } from '../support/utils';

describe( 'a11y', () => {
beforeAll( async () => {
await newDesktopBrowserPage();
await newPost();
} );

Expand Down
3 changes: 2 additions & 1 deletion test/e2e/specs/adding-blocks.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
* Internal dependencies
*/
import '../support/bootstrap';
import { newPost } from '../support/utils';
import { newPost, newDesktopBrowserPage } from '../support/utils';

describe( 'adding blocks', () => {
beforeAll( async () => {
await newDesktopBrowserPage();
await newPost();
} );

Expand Down
3 changes: 2 additions & 1 deletion test/e2e/specs/hello.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
* Internal dependencies
*/
import '../support/bootstrap';
import { newPost, visitAdmin } from '../support/utils';
import { newPost, visitAdmin, newDesktopBrowserPage } from '../support/utils';

describe( 'hello', () => {
beforeAll( async () => {
await newDesktopBrowserPage();
await newPost();
} );

Expand Down
6 changes: 2 additions & 4 deletions test/e2e/specs/managing-links.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@
* Internal dependencies
*/
import '../support/bootstrap';
import { newPost } from '../support/utils';
import { newPost, newDesktopBrowserPage } from '../support/utils';

describe( 'Managing links', () => {
beforeEach( async () => {
await newDesktopBrowserPage();
await newPost();
await page.on( 'dialog', async dialog => {
await dialog.accept();
} );
} );

const setFixedToolbar = async ( b ) => {
Expand Down
3 changes: 2 additions & 1 deletion test/e2e/specs/multi-block-selection.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
* Internal dependencies
*/
import '../support/bootstrap';
import { newPost } from '../support/utils';
import { newPost, newDesktopBrowserPage } from '../support/utils';

describe( 'Multi-block selection', () => {
beforeAll( async () => {
await newDesktopBrowserPage();
await newPost();
} );

Expand Down
4 changes: 1 addition & 3 deletions test/e2e/support/bootstrap.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import puppeteer from 'puppeteer';

// The Jest timeout is increased because these tests are a bit slow
jest.setTimeout( 50000 );
jest.setTimeout( 100000 );

beforeAll( async () => {
global.browser = await puppeteer.launch();
global.page = await browser.newPage();
await page.setViewport( { width: 1000, height: 700 } );
} );

afterAll( async () => {
Expand Down
6 changes: 6 additions & 0 deletions test/e2e/support/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,9 @@ export async function visitAdmin( adminPath ) {
export async function newPost() {
await visitAdmin( 'post-new.php' );
}

export async function newDesktopBrowserPage() {
global.page = await browser.newPage();
await page.setViewport( { width: 1000, height: 700 } );
await page.setDefaultNavigationTimeout( 60000 );
}

0 comments on commit e35fbfa

Please sign in to comment.