diff --git a/packages/scripts/README.md b/packages/scripts/README.md index 0c1687ed49f9c2..e6bc450c54ba00 100644 --- a/packages/scripts/README.md +++ b/packages/scripts/README.md @@ -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. diff --git a/packages/scripts/scripts/test-e2e.js b/packages/scripts/scripts/test-e2e.js index 8105891c8d838b..374ebc59f6fbe5 100644 --- a/packages/scripts/scripts/test-e2e.js +++ b/packages/scripts/scripts/test-e2e.js @@ -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 ) ] );