Skip to content

Commit

Permalink
fix(vite): change coverage path (#13867)
Browse files Browse the repository at this point in the history
(cherry picked from commit bb65968)
  • Loading branch information
mandarini authored and FrozenPandaz committed Dec 19, 2022
1 parent fc4fe92 commit ea4fc10
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 0 deletions.
4 changes: 4 additions & 0 deletions docs/generated/packages/vite.json
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,10 @@
"type": "boolean",
"default": false,
"description": "Enable coverage report"
},
"reportsDirectory": {
"type": "string",
"description": "Directory to write coverage report to."
}
},
"required": [],
Expand Down
1 change: 1 addition & 0 deletions packages/vite/src/executors/test/schema.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ export interface VitestExecutorOptions {
reporters?: string[];
watch?: boolean;
update?: boolean;
reportsDirectory?: string;
}
4 changes: 4 additions & 0 deletions packages/vite/src/executors/test/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@
"type": "boolean",
"default": false,
"description": "Enable coverage report"
},
"reportsDirectory": {
"type": "string",
"description": "Directory to write coverage report to."
}
},
"required": [],
Expand Down
3 changes: 3 additions & 0 deletions packages/vite/src/executors/test/vitest.impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ export default async function* runExecutor(
...options,
root: projectRoot,
reporters: [...(options.reporters ?? []), 'default', nxReporter],
coverage: {
reportsDirectory: options.reportsDirectory,
},
});

let hasErrors = false;
Expand Down
5 changes: 5 additions & 0 deletions packages/vite/src/utils/generator-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ export function addOrChangeTestTarget(

const testOptions: VitestExecutorOptions = {
passWithNoTests: true,
reportsDirectory: joinPathFragments(
'{workspaceRoot}',
'coverage',
'{projectRoot}'
),
};

if (targets[target]) {
Expand Down

0 comments on commit ea4fc10

Please sign in to comment.