Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bypass command #2393

Merged
merged 3 commits into from
May 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/beige-toes-invent.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'modular-scripts': patch
---

Fix --bypass flag in test command
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
6 changes: 3 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down