diff --git a/.changeset/beige-toes-invent.md b/.changeset/beige-toes-invent.md new file mode 100644 index 000000000..c840c8faf --- /dev/null +++ b/.changeset/beige-toes-invent.md @@ -0,0 +1,5 @@ +--- +'modular-scripts': patch +--- + +Fix --bypass flag in test command 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 diff --git a/yarn.lock b/yarn.lock index 561a7f989..3ea23f11f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4514,9 +4514,9 @@ caniuse-api@^3.0.0: lodash.uniq "^4.5.0" caniuse-lite@^1.0.0, caniuse-lite@^1.0.30001332, caniuse-lite@^1.0.30001400, caniuse-lite@^1.0.30001426: - version "1.0.30001434" - resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001434.tgz" - integrity sha512-aOBHrLmTQw//WFa2rcF1If9fa3ypkC1wzqqiKHgfdrXTWcU8C4gKVZT77eQAPWN1APys3+uQ0Df07rKauXGEYA== + version "1.0.30001488" + resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001488.tgz" + integrity sha512-NORIQuuL4xGpIy6iCCQGN4iFjlBXtfKWIenlUuyZJumLRIindLb7wXM+GO8erEhb7vXfcnf4BAg2PrSDN5TNLQ== capital-case@^1.0.4: version "1.0.4"