Skip to content

Commit

Permalink
Fix bypass command
Browse files Browse the repository at this point in the history
  • Loading branch information
AlbertoBrusa committed May 19, 2023
1 parent b86365f commit 1f7eec8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion packages/modular-scripts/src/program.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
11 changes: 5 additions & 6 deletions packages/modular-scripts/src/test/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,14 @@ async function test(options: TestOptions, packages?: string[]): Promise<void> {
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));
Expand All @@ -133,10 +135,7 @@ async function test(options: TestOptions, packages?: string[]): Promise<void> {

// 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
Expand Down

0 comments on commit 1f7eec8

Please sign in to comment.