Skip to content

Commit

Permalink
[14494] - Improve e2e testing docs and add cli args. (#14717)
Browse files Browse the repository at this point in the history
* Updated readme and added local arg.

* Lint fixes.

* Replaced dumb namings with a more reasonable ones.

* Added --wordpress- to cleanUpPrefixes.

* Align argument name with env key.
  • Loading branch information
Vadim Nicolai authored and gziolo committed Apr 1, 2019
1 parent fcbeecc commit a61e351
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
3 changes: 3 additions & 0 deletions packages/scripts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,9 @@ This is how you execute those scripts using the presented setup:

* `npm run test:e2e` - runs all unit tests.
* `npm run test:e2e:help` - prints all available options to configure unit tests runner.
* `npm run test-e2e -- --puppeteer-interactive` - runs all unit tests interactively.
* `npm run test-e2e FILE_NAME -- --puppeteer-interactive ` - runs one test file interactively.
* `npm run test-e2e:watch -- --puppeteer-interactive` - runs all tests interactively and watch for changes.

This script automatically detects the best config to start Puppeteer but sometimes you may need to specify custom options:
- You can add a `jest-puppeteer.config.js` at the root of the project or define a custom path using `JEST_PUPPETEER_CONFIG` environment variable. Check [jest-puppeteer](https://github.com/smooth-code/jest-puppeteer#jest-puppeteerconfigjs) for more details.
Expand Down
16 changes: 14 additions & 2 deletions packages/scripts/scripts/test-e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,23 @@ const runInBand = ! hasRunInBand ?
[ '--runInBand' ] :
[];

const cleanUpPrefixes = [ '--puppeteer-' ];

if ( hasCliArg( '--puppeteer-interactive' ) ) {
process.env.PUPPETEER_HEADLESS = 'false';
process.env.PUPPETEER_SLOWMO = getCliArg( '--puppeteer-slowmo' ) || 80;
}

const configsMapping = {
WP_BASE_URL: '--wordpress-base-url',
WP_USERNAME: '--wordpress-username',
WP_PASSWORD: '--wordpress-password',
};

Object.entries( configsMapping ).forEach( ( [ envKey, argName ] ) => {
if ( hasCliArg( argName ) ) {
process.env[ envKey ] = getCliArg( argName );
}
} );

const cleanUpPrefixes = [ '--puppeteer-', '--wordpress-' ];

jest.run( [ ...config, ...runInBand, ...getCliArgs( cleanUpPrefixes ) ] );

0 comments on commit a61e351

Please sign in to comment.