Skip to content

Commit 9af4f76

Browse files
committed
fix(@angular/build): update vitest to 4.0.6 and remove coverage workaround
Upgrades Vitest and @vitest/coverage-v8 dependencies to version 4.0.6. This update allows for the removal of a temporary workaround that augmented `BaseCoverageProvider.prototype.isIncluded` in `executor.ts`. The issue with direct filesystem checks in Vitest's coverage provider has been resolved in version 4.0.6, simplifying the code and relying on the official library's implementation.
1 parent 2a24469 commit 9af4f76

File tree

5 files changed

+59
-76
lines changed

5 files changed

+59
-76
lines changed

modules/testing/builder/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
"@angular-devkit/architect": "workspace:*",
55
"@angular/ssr": "workspace:*",
66
"@angular-devkit/build-angular": "workspace:*",
7-
"@vitest/coverage-v8": "4.0.4",
7+
"@vitest/coverage-v8": "4.0.6",
88
"jsdom": "27.0.1",
99
"rxjs": "7.8.2",
10-
"vitest": "4.0.4"
10+
"vitest": "4.0.6"
1111
}
1212
}

packages/angular/build/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
"ng-packagr": "21.0.0-rc.0",
5757
"postcss": "8.5.6",
5858
"rxjs": "7.8.2",
59-
"vitest": "4.0.4"
59+
"vitest": "4.0.6"
6060
},
6161
"peerDependencies": {
6262
"@angular/core": "0.0.0-ANGULAR-FW-PEER-DEP",
@@ -74,7 +74,7 @@
7474
"tailwindcss": "^2.0.0 || ^3.0.0 || ^4.0.0",
7575
"tslib": "^2.3.0",
7676
"typescript": ">=5.9 <6.0",
77-
"vitest": "^4.0.0"
77+
"vitest": "^4.0.6"
7878
},
7979
"peerDependenciesMeta": {
8080
"@angular/core": {

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

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,7 @@ export class VitestExecutor implements TestExecutor {
143143
} = this.options;
144144

145145
let vitestNodeModule;
146-
let vitestCoverageModule;
147146
try {
148-
vitestCoverageModule = await import('vitest/coverage');
149147
vitestNodeModule = await import('vitest/node');
150148
} catch (error: unknown) {
151149
assertIsError(error);
@@ -158,21 +156,6 @@ export class VitestExecutor implements TestExecutor {
158156
}
159157
const { startVitest } = vitestNodeModule;
160158

161-
// Augment BaseCoverageProvider to include logic to support the built virtual files.
162-
// Temporary workaround to avoid the direct filesystem checks in the base provider that
163-
// were introduced in v4. Also ensures that all built virtual files are available.
164-
const builtVirtualFiles = this.buildResultFiles;
165-
vitestCoverageModule.BaseCoverageProvider.prototype.isIncluded = function (filename) {
166-
const relativeFilename = path.relative(workspaceRoot, filename);
167-
if (!this.options.include || builtVirtualFiles.has(relativeFilename)) {
168-
return !isMatch(relativeFilename, this.options.exclude);
169-
} else {
170-
return isMatch(relativeFilename, this.options.include, {
171-
ignore: this.options.exclude,
172-
});
173-
}
174-
};
175-
176159
// Setup vitest browser options if configured
177160
const browserOptions = await setupBrowserConfiguration(
178161
browsers,

pnpm-lock.yaml

Lines changed: 54 additions & 54 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/legacy-cli/e2e/utils/vitest.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { updateJsonFile } from './project';
33

44
/** Updates the `test` builder in the current workspace to use Vitest. */
55
export async function applyVitestBuilder(): Promise<void> {
6-
await silentNpm('install', 'vitest@4.0.0', 'jsdom@27.0.0', '--save-dev');
6+
await silentNpm('install', 'vitest@4.0.6', 'jsdom@27.0.0', '--save-dev');
77

88
await updateJsonFile('angular.json', (json) => {
99
const projects = Object.values(json['projects']);

0 commit comments

Comments
 (0)