From 3cc3c8973e76698e3e5e1f3a052394fe69048335 Mon Sep 17 00:00:00 2001 From: andrei draganescu Date: Fri, 15 Mar 2019 20:05:05 +0900 Subject: [PATCH] Update/e2e tests options (#14129) * added an interactive argument to the test-e2e script * mend * added a way to bypass certain args from Jest, reverted to normal argument passing using double dash * simplified the argument cleanup function * simplified the argument cleanup function * added a way to bypass certain args from Jest, reverted to normal argument passing using double dash * simplified the argument cleanup function * simplified the argument cleanup function * cleaned up the code by moving the prefixed arguments removal to getcliargs --- packages/scripts/scripts/test-e2e.js | 10 +++++++++- packages/scripts/utils/index.js | 2 ++ packages/scripts/utils/process.js | 10 +++++++++- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/packages/scripts/scripts/test-e2e.js b/packages/scripts/scripts/test-e2e.js index fc2e8b42f345d6..8105891c8d838b 100644 --- a/packages/scripts/scripts/test-e2e.js +++ b/packages/scripts/scripts/test-e2e.js @@ -19,6 +19,7 @@ const jest = require( 'jest' ); */ const { fromConfigRoot, + getCliArg, getCliArgs, hasCliArg, hasProjectFile, @@ -42,4 +43,11 @@ const runInBand = ! hasRunInBand ? [ '--runInBand' ] : []; -jest.run( [ ...config, ...runInBand, ...getCliArgs() ] ); +const cleanUpPrefixes = [ '--puppeteer-' ]; + +if ( hasCliArg( '--puppeteer-interactive' ) ) { + process.env.PUPPETEER_HEADLESS = 'false'; + process.env.PUPPETEER_SLOWMO = getCliArg( '--puppeteer-slowmo' ) || 80; +} + +jest.run( [ ...config, ...runInBand, ...getCliArgs( cleanUpPrefixes ) ] ); diff --git a/packages/scripts/utils/index.js b/packages/scripts/utils/index.js index 0837f7ab80996e..aebbcdca718007 100644 --- a/packages/scripts/utils/index.js +++ b/packages/scripts/utils/index.js @@ -6,6 +6,7 @@ const { getCliArgs, hasCliArg, spawnScript, + cleanUpArgs, } = require( './cli' ); const { getWebpackArgs, @@ -35,4 +36,5 @@ module.exports = { hasPackageProp, hasProjectFile, spawnScript, + cleanUpArgs, }; diff --git a/packages/scripts/utils/process.js b/packages/scripts/utils/process.js index f8d3a0f6b20575..cfa38afa26aa94 100644 --- a/packages/scripts/utils/process.js +++ b/packages/scripts/utils/process.js @@ -1,4 +1,12 @@ -const getCliArgs = () => process.argv.slice( 2 ); +const getCliArgs = ( excludePrefixes ) => { + const args = process.argv.slice( 2 ); + if ( excludePrefixes ) { + return args.filter( ( arg ) => { + return ! excludePrefixes.some( ( prefix ) => arg.startsWith( prefix ) ); + } ); + } + return args; +}; module.exports = { exit: process.exit,