diff --git a/packages/cli/src/commands/test.js b/packages/cli/src/commands/test.js index 3b74e62c5724..60ff87492092 100644 --- a/packages/cli/src/commands/test.js +++ b/packages/cli/src/commands/test.js @@ -34,12 +34,7 @@ export const builder = (yargs) => { describe: 'Run tests related to changed files based on hg/git. Specify the name or path to a file to focus on a specific set of tests', type: 'boolean', - default: false, - }) - .option('watchAll', { - describe: 'Run all tests', - type: 'boolean', - default: false, + default: true, }) .option('collectCoverage', { describe: @@ -63,35 +58,37 @@ export const builder = (yargs) => { export const handler = async ({ side, - watch = false, - watchAll = false, + watch = true, collectCoverage = false, }) => { const { cache: CACHE_DIR } = getPaths() const sides = [].concat(side).filter(Boolean) const args = [ '--passWithNoTests', - watch && '--watch', collectCoverage && '--collectCoverage', - watchAll && '--watchAll', ].filter(Boolean) - // If you don't pass any arguments we enter "watch mode" as the default. - if (!process.env.CI && !watchAll && !collectCoverage) { - // https://github.com/facebook/create-react-app/issues/5210 + + // If the user wants to watch, set the proper watch flag based on what kind of repo this is + // because of https://github.com/facebook/create-react-app/issues/5210 + if (watch && !process.env.CI && !collectCoverage) { const hasSourceControl = isInGitRepository() || isInMercurialRepository() args.push(hasSourceControl ? '--watch' : '--watchAll') } + // if no sides declared with yargs, default to all sides if (!sides.length) { getProject().sides.forEach(side => sides.push(side)) } + args.push( '--config', require.resolve('@redwoodjs/core/config/jest.config.js') ) + if (sides.length > 0) { args.push('--projects', ...sides) } + try { // Create a test database if (sides.includes('api')) {