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,