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 7417eb5 commit 8c0bc90
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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 8c0bc90

Please sign in to comment.