Skip to content
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
1 change: 1 addition & 0 deletions goldens/public-api/angular/build/index.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ export type UnitTestBuilderOptions = {
runner?: Runner;
setupFiles?: string[];
tsConfig?: string;
ui?: boolean;
watch?: boolean;
};

Expand Down
18 changes: 16 additions & 2 deletions packages/angular/build/src/builders/unit-test/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,12 @@ export async function normalizeOptions(
const buildTargetSpecifier = options.buildTarget ?? `::development`;
const buildTarget = targetFromTargetString(buildTargetSpecifier, projectName, 'build');

const { runner, browsers, progress, filter, browserViewport } = options;
const { runner, browsers, progress, filter, browserViewport, ui } = options;

if (ui && runner !== 'vitest') {
throw new Error('The "ui" option is only available for the "vitest" runner.');
}

const [width, height] = browserViewport?.split('x').map(Number) ?? [];

let tsConfig = options.tsConfig;
Expand All @@ -71,6 +76,14 @@ export async function normalizeOptions(
}
}

let watch = options.watch ?? isTTY();
if (options.ui && options.watch === false) {
context.logger.warn(
`The '--ui' option requires watch mode. The '--no-watch' flag will be ignored.`,
);
watch = true;
}

return {
// Project/workspace information
workspaceRoot,
Expand Down Expand Up @@ -105,8 +118,9 @@ export async function normalizeOptions(
outputFile: options.outputFile,
browsers,
browserViewport: width && height ? { width, height } : undefined,
watch: options.watch ?? isTTY(),
watch,
debug: options.debug ?? false,
ui: options.ui ?? false,
providersFile: options.providersFile && path.join(workspaceRoot, options.providersFile),
setupFiles: options.setupFiles
? options.setupFiles.map((setupFile) => path.join(workspaceRoot, setupFile))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ export class VitestExecutor implements TestExecutor {
debug,
watch,
browserViewport,
ui,
} = this.options;
let vitestNodeModule;
try {
Expand Down Expand Up @@ -201,6 +202,7 @@ export class VitestExecutor implements TestExecutor {
reporters: reporters ?? ['default'],
outputFile,
watch,
ui,
coverage: await generateCoverageOption(coverage, this.projectName),
...debugOptions,
},
Expand Down
5 changes: 5 additions & 0 deletions packages/angular/build/src/builders/unit-test/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@
"description": "Enables debugging mode for tests, allowing the use of the Node Inspector.",
"default": false
},
"ui": {
"type": "boolean",
"description": "Enables the Vitest UI for interactive test execution. This option is only available for the Vitest runner.",
"default": false
},
"coverage": {
"type": "boolean",
"description": "Enables coverage reporting for tests.",
Expand Down