From 00e5cc64a9416f75d5eb5a943d43a740e18d80e3 Mon Sep 17 00:00:00 2001 From: Vadim Nicolai Date: Sat, 30 Mar 2019 00:05:37 +0200 Subject: [PATCH 1/5] Updated readme and added local arg. --- packages/scripts/README.md | 3 +++ packages/scripts/scripts/test-e2e.js | 12 ++++++++++++ 2 files changed, 15 insertions(+) diff --git a/packages/scripts/README.md b/packages/scripts/README.md index 0c1687ed49f9c..e6bc450c54ba0 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 8105891c8d838..7701a7184ec94 100644 --- a/packages/scripts/scripts/test-e2e.js +++ b/packages/scripts/scripts/test-e2e.js @@ -50,4 +50,16 @@ if ( hasCliArg( '--puppeteer-interactive' ) ) { process.env.PUPPETEER_SLOWMO = getCliArg( '--puppeteer-slowmo' ) || 80; } +const configsMapping = { + WP_BASE_URL: "--wordpress-host", + WP_USERNAME: "--wordpress-username", + WP_PASSWORD: "--wordpress-password" +}; + +Object.entries(configsMapping).forEach(([key, value]) => { + if (hasCliArg(value)) { + process.env[key] = getCliArg(value); + } +}); + jest.run( [ ...config, ...runInBand, ...getCliArgs( cleanUpPrefixes ) ] ); From 72be60ed94bdf5062d1c6ebdc4530e143960a567 Mon Sep 17 00:00:00 2001 From: Vadim Nicolai Date: Sun, 31 Mar 2019 13:57:22 +0300 Subject: [PATCH 2/5] Lint fixes. --- packages/scripts/scripts/test-e2e.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/scripts/scripts/test-e2e.js b/packages/scripts/scripts/test-e2e.js index 7701a7184ec94..4ba292d8d3939 100644 --- a/packages/scripts/scripts/test-e2e.js +++ b/packages/scripts/scripts/test-e2e.js @@ -51,15 +51,15 @@ if ( hasCliArg( '--puppeteer-interactive' ) ) { } const configsMapping = { - WP_BASE_URL: "--wordpress-host", - WP_USERNAME: "--wordpress-username", - WP_PASSWORD: "--wordpress-password" + WP_BASE_URL: '--wordpress-host', + WP_USERNAME: '--wordpress-username', + WP_PASSWORD: '--wordpress-password', }; -Object.entries(configsMapping).forEach(([key, value]) => { - if (hasCliArg(value)) { - process.env[key] = getCliArg(value); +Object.entries( configsMapping ).forEach( ( [ key, value ] ) => { + if ( hasCliArg( value ) ) { + process.env[ key ] = getCliArg( value ); } -}); +} ); jest.run( [ ...config, ...runInBand, ...getCliArgs( cleanUpPrefixes ) ] ); From 3155ed288ed7edaa4029904d3cd710d08a2bee51 Mon Sep 17 00:00:00 2001 From: Vadim Nicolai Date: Mon, 1 Apr 2019 11:13:31 +0300 Subject: [PATCH 3/5] Replaced dumb namings with a more reasonable ones. --- packages/scripts/scripts/test-e2e.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/scripts/scripts/test-e2e.js b/packages/scripts/scripts/test-e2e.js index 4ba292d8d3939..cfac80b34e339 100644 --- a/packages/scripts/scripts/test-e2e.js +++ b/packages/scripts/scripts/test-e2e.js @@ -56,9 +56,9 @@ const configsMapping = { WP_PASSWORD: '--wordpress-password', }; -Object.entries( configsMapping ).forEach( ( [ key, value ] ) => { - if ( hasCliArg( value ) ) { - process.env[ key ] = getCliArg( value ); +Object.entries( configsMapping ).forEach( ( [ envKey, argName ] ) => { + if ( hasCliArg( argName ) ) { + process.env[ envKey ] = getCliArg( argName ); } } ); From 32646780e97c2e223f2c69e46a4b13a824325160 Mon Sep 17 00:00:00 2001 From: Vadim Nicolai Date: Mon, 1 Apr 2019 11:29:52 +0300 Subject: [PATCH 4/5] Added --wordpress- to cleanUpPrefixes. --- packages/scripts/scripts/test-e2e.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/scripts/scripts/test-e2e.js b/packages/scripts/scripts/test-e2e.js index cfac80b34e339..b2d644831fecf 100644 --- a/packages/scripts/scripts/test-e2e.js +++ b/packages/scripts/scripts/test-e2e.js @@ -43,8 +43,6 @@ const runInBand = ! hasRunInBand ? [ '--runInBand' ] : []; -const cleanUpPrefixes = [ '--puppeteer-' ]; - if ( hasCliArg( '--puppeteer-interactive' ) ) { process.env.PUPPETEER_HEADLESS = 'false'; process.env.PUPPETEER_SLOWMO = getCliArg( '--puppeteer-slowmo' ) || 80; @@ -62,4 +60,6 @@ Object.entries( configsMapping ).forEach( ( [ envKey, argName ] ) => { } } ); +const cleanUpPrefixes = [ '--puppeteer-', '--wordpress-' ]; + jest.run( [ ...config, ...runInBand, ...getCliArgs( cleanUpPrefixes ) ] ); From 6784492a056d0f625546be4544aad4fbbf564eff Mon Sep 17 00:00:00 2001 From: Vadim Nicolai Date: Mon, 1 Apr 2019 11:32:41 +0300 Subject: [PATCH 5/5] Align argument name with env key. --- packages/scripts/scripts/test-e2e.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/scripts/scripts/test-e2e.js b/packages/scripts/scripts/test-e2e.js index b2d644831fecf..374ebc59f6fbe 100644 --- a/packages/scripts/scripts/test-e2e.js +++ b/packages/scripts/scripts/test-e2e.js @@ -49,7 +49,7 @@ if ( hasCliArg( '--puppeteer-interactive' ) ) { } const configsMapping = { - WP_BASE_URL: '--wordpress-host', + WP_BASE_URL: '--wordpress-base-url', WP_USERNAME: '--wordpress-username', WP_PASSWORD: '--wordpress-password', };