Skip to content

Commit

Permalink
feat(vitest-angular): add UI and coverage options to test builder (#1521
Browse files Browse the repository at this point in the history
)
  • Loading branch information
jorgeandrespadilla authored Dec 26, 2024
1 parent 0d79efb commit 026b3dc
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
2 changes: 2 additions & 0 deletions packages/vitest-angular/src/lib/builders/test/schema.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ export interface VitestSchema {
reportsDirectory?: string;
testFiles?: string[];
watch?: boolean;
ui?: boolean;
coverage?: boolean;
}
8 changes: 8 additions & 0 deletions packages/vitest-angular/src/lib/builders/test/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@
"watch": {
"description": "Watch files for changes and rerun tests related to changed files.",
"type": "boolean"
},
"ui": {
"description": "Run tests using Vitest UI Mode.",
"type": "boolean"
},
"coverage": {
"description": "Enable code coverage analysis.",
"type": "boolean"
}
},
"required": []
Expand Down
9 changes: 8 additions & 1 deletion packages/vitest-angular/src/lib/builders/test/vitest.impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,19 @@ async function vitestBuilder(
const projectConfig = await context.getProjectMetadata(
context.target as unknown as string
);
const extraArgs = await getExtraArgs(options);
const { coverageArgs, ...extraArgs } = await getExtraArgs(options);
const watch = options.watch === true;
const ui = options.ui === true;
const coverageEnabled = options.coverage === true;
const config = {
root: `${projectConfig['root'] || '.'}`,
watch,
ui,
config: options.configFile,
coverage: {
enabled: coverageEnabled,
...coverageArgs,
},
...extraArgs,
};

Expand Down

0 comments on commit 026b3dc

Please sign in to comment.