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

Testing: Experiment with Puppeteer for E2E testing #5618

Merged
merged 16 commits into from
Mar 23, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
More stable tests by increasing timeouts and launching a new page on …
…each test
  • Loading branch information
youknowriad committed Mar 21, 2018
commit e35fbfa63613f6f74ca3f8efbddf3fbcabbba2a5
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';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment for dependencies is missing.


// 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 );
}