From 32c5e5b40fe8a3ed62c70aed6cbce4849c280d0f Mon Sep 17 00:00:00 2001 From: Charles Lyding <19598772+clydin@users.noreply.github.com> Date: Thu, 15 May 2025 17:51:02 -0400 Subject: [PATCH] fix(@angular/build): enable unit-test builder watch outside CI When using the experimental `unit-test` builder, the `watch` option will now default to true when there is an interactive terminal and not on CI. This more closely aligns with the behavior of the existing `karma` builder and that of vitest itself. CI is determined by the presence of a truthy `CI` environment variable. --- packages/angular/build/src/builders/unit-test/options.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/angular/build/src/builders/unit-test/options.ts b/packages/angular/build/src/builders/unit-test/options.ts index ec2e0402a507..7f1413051f91 100644 --- a/packages/angular/build/src/builders/unit-test/options.ts +++ b/packages/angular/build/src/builders/unit-test/options.ts @@ -10,6 +10,7 @@ import { type BuilderContext, targetFromTargetString } from '@angular-devkit/arc import path from 'node:path'; import { normalizeCacheOptions } from '../../utils/normalize-cache'; import { getProjectRootPaths } from '../../utils/project-metadata'; +import { isTTY } from '../../utils/tty'; import type { Schema as UnitTestOptions } from './schema'; export type NormalizedUnitTestOptions = Awaited>; @@ -32,8 +33,7 @@ export async function normalizeOptions( const buildTargetSpecifier = options.buildTarget ?? `::development`; const buildTarget = targetFromTargetString(buildTargetSpecifier, projectName, 'build'); - const { codeCoverage, codeCoverageExclude, tsConfig, runner, reporters, browsers, watch } = - options; + const { codeCoverage, codeCoverageExclude, tsConfig, runner, reporters, browsers } = options; return { // Project/workspace information @@ -51,7 +51,7 @@ export async function normalizeOptions( tsConfig, reporters, browsers, - watch, + watch: options.watch ?? isTTY(), debug: options.debug ?? false, providersFile: options.providersFile && path.join(workspaceRoot, options.providersFile), };