8000 fix(@angular/build): set coverage report directory to coverage/projec… · angular/angular-cli@705af22 · GitHub
[go: up one dir, main page]

Skip to content

Commit 705af22

Browse files
cexbrayatclydin
authored andcommitted
fix(@angular/build): set coverage report directory to coverage/project-name
1 parent 049eb55 commit 705af22

File tree

5 files changed

+13
-12
lines changed

5 files changed

+13
-12
lines changed

packages/angular/build/src/builders/unit-test/runners/vitest/executor.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import {
2020
ResultKind,
2121
} from '../../../application/results';
2222
import { NormalizedUnitTestBuilderOptions } from '../../options';
23-
import { findTests, getTestEntrypoints } from '../../test-discovery';
2423
import type { TestExecutor } from '../api';
2524
import { setupBrowserConfiguration } from './browser-provider';
2625
import { createVitestPlugins } from './plugins';
@@ -191,7 +190,7 @@ export class VitestExecutor implements TestExecutor {
191190
reporters: reporters ?? ['default'],
192191
outputFile,
193192
watch,
194-
coverage: generateCoverageOption(codeCoverage),
193+
coverage: generateCoverageOption(codeCoverage, this.projectName),
195194
...debugOptions,
196195
},
197196
{
@@ -208,6 +207,7 @@ export class VitestExecutor implements TestExecutor {
208207

209208
function generateCoverageOption(
210209
codeCoverage: NormalizedUnitTestBuilderOptions['codeCoverage'],
210+
projectName: string,
211211
): VitestCoverageOption {
212212
if (!codeCoverage) {
213213
return {
@@ -218,6 +218,7 @@ function generateCoverageOption(
218218
return {
219219
enabled: true,
220220
excludeAfterRemap: true,
221+
reportsDirectory: toPosixPath(path.join('coverage', projectName)),
221222
// Special handling for `exclude`/`reporters` due to an undefined value causing upstream failures
222223
...(codeCoverage.exclude ? { exclude: codeCoverage.exclude } : {}),
223224
...(codeCoverage.reporters

packages/angular/build/src/builders/unit-test/tests/options/code-coverage-exclude_spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ describeBuilder(execute, UNIT_TEST_BUILDER_INFO, (harness) => {
3131

3232
const { result } = await harness.executeOnce();
3333
expect(result?.success).toBeTrue();
34-
const summary = harness.readFile('coverage/coverage-final.json');
34+
const summary = harness.readFile('coverage/test/coverage-final.json');
3535
expect(summary).toContain('src/app/error.ts"');
3636
});
3737

@@ -44,7 +44,7 @@ describeBuilder(execute, UNIT_TEST_BUILDER_INFO, (harness) => {
4444

4545
const { result } = await harness.executeOnce();
4646
expect(result?.success).toBeTrue();
47-
const summary = harness.readFile('coverage/coverage-final.json');
47+
const summary = harness.readFile('coverage/test/coverage-final.json');
4848
expect(summary).not.toContain('src/app/error.ts"');
4949
});
5050
});

packages/angular/build/src/builders/unit-test/tests/options/code-coverage-reporters_spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ describeBuilder(execute, UNIT_TEST_BUILDER_INFO, (harness) => {
2929

3030
const { result } = await harness.executeOnce();
3131
expect(result?.success).toBeTrue();
32-
expect(harness.hasFile('coverage/coverage-summary.json')).toBeTrue();
32+
expect(harness.hasFile('coverage/test/coverage-summary.json')).toBeTrue();
3333
});
3434

3535
it('should generate multiple reports when specified', async () => {
@@ -41,8 +41,8 @@ describeBuilder(execute, UNIT_TEST_BUILDER_INFO, (harness) => {
4141

4242
const { result } = await harness.executeOnce();
4343
expect(result?.success).toBeTrue();
44-
expect(harness.hasFile('coverage/coverage-summary.json')).toBeTrue();
45-
expect(harness.hasFile('coverage/lcov.info')).toBeTrue();
44+
expect(harness.hasFile('coverage/test/coverage-summary.json')).toBeTrue();
45+
expect(harness.hasFile('coverage/test/lcov.info')).toBeTrue();
4646
});
4747
});
4848
});

packages/angular/build/src/builders/unit-test/tests/options/code-coverage_spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ describeBuilder(execute, UNIT_TEST_BUILDER_INFO, (harness) => {
2828

2929
const { result } = await harness.executeOnce();
3030
expect(result?.success).toBeTrue();
31-
expect(harness.hasFile('coverage/index.html')).toBeFalse();
31+
expect(harness.hasFile('coverage/test/index.html')).toBeFalse();
3232
});
3333

3434
it('should generate a code coverage report when codeCoverage is true', async () => {
@@ -39,7 +39,7 @@ describeBuilder(execute, UNIT_TEST_BUILDER_INFO, (harness) => {
3939

4040
const { result } = await harness.executeOnce();
4141
expect(result?.success).toBeTrue();
42-
expect(harness.hasFile('coverage/index.html')).toBeTrue();
42+
expect(harness.hasFile('coverage/test/index.html')).toBeTrue();
4343
});
4444
});
4545
});

packages/angular/build/src/builders/unit-test/tests/setup.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { readFileSync } from 'node:fs';
1111
import path from 'node:path';
1212
import { BuilderHarness } from '../../../../../../../modules/testing/builder/src';
1313
import {
14-
ApplicationBuilderOptions as AppilicationSchema,
14+
ApplicationBuilderOptions as ApplicationSchema,
1515
buildApplication,
1616
} from '../../../builders/application';
1717
import { Schema } from '../schema';
@@ -33,7 +33,7 @@ export const APPLICATION_BUILDER_INFO = Object.freeze({
3333
* Contains all required application builder fields.
3434
* Also disables progress reporting to minimize logging output.
3535
*/
36-
export const APPLICATION_BASE_OPTIONS = Object.freeze<AppilicationSchema>({
36+
export const APPLICATION_BASE_OPTIONS = Object.freeze<ApplicationSchema>({
3737
index: 'src/index.html',
3838
browser: 'src/main.ts',
3939
outputPath: 'dist',
@@ -84,7 +84,7 @@ let applicationSchema: json.schema.JsonSchema | undefined;
8484
*/
8585
export function setupApplicationTarget<T>(
8686
harness: BuilderHarness<T>,
87-
extraOptions?: Partial<AppilicationSchema>,
87+
extraOptions?: Partial<ApplicationSchema>,
8888
): void {
8989
applicationSchema ??= JSON.parse(
9090
readFileSync(APPLICATION_BUILDER_INFO.schemaPath, 'utf8'),

0 commit comments

Comments
 (0)
0