From 1f7eec8e5e6dec841ed63a2cd73521cc3f965b4f Mon Sep 17 00:00:00 2001 From: Alberto Brusa Date: Fri, 19 May 2023 17:06:46 +0100 Subject: [PATCH] Fix bypass command --- packages/modular-scripts/src/program.ts | 2 +- packages/modular-scripts/src/test/index.ts | 11 +++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/packages/modular-scripts/src/program.ts b/packages/modular-scripts/src/program.ts index df62d8efc..75c8fc916 100755 --- a/packages/modular-scripts/src/program.ts +++ b/packages/modular-scripts/src/program.ts @@ -174,7 +174,7 @@ program .command('test [packages...]') .option( '--bypass', - 'Bypass all modular specific selective behaviour and pass all flags and options directly to Jest. Ensures modular test behaves exactly like calling Jest directly, but with Modular configuration applied. Use with IntelliJ Jest configurations.', + 'Bypass all modular specific selective behavior and pass all flags and options directly to Jest, except for --verbose, --swc & --env which can be used with --bypass. Ensures modular test behaves exactly like calling Jest directly, but with Modular configuration applied. Use with IntelliJ Jest configurations.', false, ) .option( diff --git a/packages/modular-scripts/src/test/index.ts b/packages/modular-scripts/src/test/index.ts index 97f2fbb6f..0ec907cfb 100644 --- a/packages/modular-scripts/src/test/index.ts +++ b/packages/modular-scripts/src/test/index.ts @@ -118,12 +118,14 @@ async function test(options: TestOptions, packages?: string[]): Promise { let nonModularTargets; let modularTargets; + // If --bypass, pass on all options to jest if (bypass) { - // pass on all options + // Modular flags compatible with --bypass that shouldn't be passed to Jest + const bypassCompatibleFlags = ['verbose', 'env', 'swc', 'bypass']; cleanArgv.push( ...Object.entries(options) .filter(([key, v]) => { - return key !== 'jest' && key !== 'env'; + return !bypassCompatibleFlags.some((option) => key === option); }) .map(([key, v]) => { const booleanValue = /^(true)$/.exec(String(v)); @@ -133,10 +135,7 @@ async function test(options: TestOptions, packages?: string[]): Promise { // Get the options that have been incorrectly placed in packages[] if (packages) { - const additionalOptions: string[] = []; - const cleanPackages: string[] = []; - extractOptions(packages, cleanPackages, additionalOptions); - cleanArgv.push(...additionalOptions); + cleanArgv.push(...packages); } } else { // pass on jest programatic options