Skip to content

Commit

Permalink
Update/e2e tests options (#14129)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
draganescu authored and youknowriad committed Mar 20, 2019
1 parent 74fe98d commit 1ad22de
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
10 changes: 9 additions & 1 deletion packages/scripts/scripts/test-e2e.js
Expand Up @@ -19,6 +19,7 @@ const jest = require( 'jest' );
*/
const {
fromConfigRoot,
getCliArg,
getCliArgs,
hasCliArg,
hasProjectFile,
Expand All @@ -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 ) ] );
2 changes: 2 additions & 0 deletions packages/scripts/utils/index.js
Expand Up @@ -6,6 +6,7 @@ const {
getCliArgs,
hasCliArg,
spawnScript,
cleanUpArgs,
} = require( './cli' );
const {
getWebpackArgs,
Expand Down Expand Up @@ -35,4 +36,5 @@ module.exports = {
hasPackageProp,
hasProjectFile,
spawnScript,
cleanUpArgs,
};
10 changes: 9 additions & 1 deletion 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,
Expand Down

0 comments on commit 1ad22de

Please sign in to comment.