Skip to content

Commit

Permalink
[fix] Make --load-env-files work with yarn rw test (#11887)
Browse files Browse the repository at this point in the history
  • Loading branch information
Philzen authored and Tobbe committed Jan 16, 2025
1 parent 7afffbf commit 9f9d46d
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions packages/cli/src/commands/testHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,25 +71,28 @@ export const handler = async ({
const rwjsPaths = getPaths()
const forwardJestFlags = Object.keys(others).flatMap((flagName) => {
if (
['watch', 'collect-coverage', 'db-push', '$0', '_'].includes(flagName)
[
'collect-coverage',
'db-push',
'loadEnvFiles',
'watch',
'$0',
'_',
].includes(flagName)
) {
// filter out flags meant for the rw test command only
return []
} else {
// and forward on the other flags
const flag = flagName.length > 1 ? `--${flagName}` : `-${flagName}`
const flagValue = others[flagName]

if (Array.isArray(flagValue)) {
// jest does not collapse flags e.g. --coverageReporters=html --coverageReporters=text
// so we pass it on. Yargs collapses these flags into an array of values
return flagValue.flatMap((val) => {
return [flagName.length > 1 ? `--${flagName}` : `-${flagName}`, val]
})
return flagValue.flatMap((val) => [flag, val])
} else {
return [
flagName.length > 1 ? `--${flagName}` : `-${flagName}`,
flagValue,
]
return [flag, flagValue]
}
}
})
Expand Down

0 comments on commit 9f9d46d

Please sign in to comment.