Site-kit-wp: Simplify and improve E2E Puppeteer Config

Created on 24 Jul 2019  路  6Comments  路  Source: google/site-kit-wp

Bug Description

As pointed out by @aaemnnosttv, @wordpress/scripts already supports passing some custom configs to Puppeteer, so that we don't actually need to maintain a custom jest-puppeteer.config.js file.

More specifically, it allows setting PUPPETEER_HEADLESS to disable headless mode and PUPPETEER_SLOWMO to slow down tests.

Example:

PUPPETEER_HEADLESS=false npm run test:e2e
PUPPETEER_SLOWMO=200 npm run test:e2e

There's also a third option, passing a --puppeteer-interactive argument to the command that would result in non-headless mode with a slowMo value of 80. In other words, npm run test:e2e -- --puppeteer-interactive is equivalent to running

PUPPETEER_HEADLESS=false PUPPETEER_SLOWMO=80 npm run test:e2e

Second, the default config also ensures that the --runInBand argument is always passed to Jest, which can speed up tests on CI servers in some cases.


_Do not alter or remove anything below. The following sections will be managed by moderators only._

Acceptance criteria

  • More straightforward and better documented way of running E2E tests
  • Tests run serially on Travis CI

Implementation Brief

  • Remove custom jest-puppeteer.config.js file.
  • Alter documentation to suggest using PUPPETEER_HEADLESS / PUPPETEER_SLOWMO or the --puppeteer-interactive argument.
  • Add new npm script npm run test:e2e:interactive that runs npm run test:e2e -- --puppeteer-interactive
  • Add new npm script npm run test:e2e:ci that runs npm run test:e2e -- --runInBand
  • Change .travis.yml to use npm run test:e2e:ci

Changelog entry

  • N/A
P2 Enhancement

All 6 comments

See https://github.com/ampproject/amp-wp/pull/2878 for a reference implementation. It's really straightforward.

Thanks @swissspidy

It's also worth noting that PUPPETEER_SLOWMO can be set by a cli argument as well using the --puppeteer-slowmo {ms} option.

Ticket directs to alter documentation but I'm not finding existing docs regarding e2e testing. I'm happy to add docs here and wanted to confirm they should be added to the '/tests/REAMD.md' with the other testing docs in preference to the wiki. @swissspidy or @aaemnnosttv

Current documentation is in the contributor handbook: https://docs.google.com/document/d/1M1gUI0FKnP3RcbgMsU6YltEtNCHaH_9YGbH8F-7JefA/edit#heading=h.21tk21w0qtqj

My understanding is that this doc will be moved to the wiki here on GitHub eventually.

That's right, sorry for the lapse, thanks for providing the link @swissspidy.

Ready for CR and added suggestions to the contributor handbook doc.

@swissspidy QA looks good - I added a few suggestions to the handbook document as well.

Moving to Approval.

Was this page helpful?
0 / 5 - 0 ratings