Skip to content

Commit 7362199

Browse files
committed
fix(@angular/build): normalize paths for Vitest runner output files
To better ensure that file paths are matched when serving build assets across platforms, the output file paths are now normalized using Vite's `normalizePath` helper function.
1 parent e4fa5f3 commit 7362199

File tree

1 file changed

+6
-3
lines changed
  • packages/angular/build/src/builders/unit-test/runners/vitest

1 file changed

+6
-3
lines changed

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ type VitestCoverageOption = Exclude<InlineConfig['coverage'], undefined>;
2828

2929
export class VitestExecutor implements TestExecutor {
3030
private vitest: Vitest | undefined;
31+
private normalizePath: ((id: string) => string) | undefined;
3132
private readonly projectName: string;
3233
private readonly options: NormalizedUnitTestBuilderOptions;
3334
private readonly buildResultFiles = new Map<string, ResultFile>();
@@ -56,17 +57,19 @@ export class VitestExecutor implements TestExecutor {
5657
}
5758

5859
async *execute(buildResult: FullResult | IncrementalResult): AsyncIterable<BuilderOutput> {
60+
this.normalizePath ??= (await import('vite')).normalizePath;
61+
5962
if (buildResult.kind === ResultKind.Full) {
6063
this.buildResultFiles.clear();
6164
for (const [path, file] of Object.entries(buildResult.files)) {
62-
this.buildResultFiles.set(path, file);
65+
this.buildResultFiles.set(this.normalizePath(path), file);
6366
}
6467
} else {
6568
for (const file of buildResult.removed) {
66-
this.buildResultFiles.delete(file.path);
69+
this.buildResultFiles.delete(this.normalizePath(file.path));
6770
}
6871
for (const [path, file] of Object.entries(buildResult.files)) {
69-
this.buildResultFiles.set(path, file);
72+
this.buildResultFiles.set(this.normalizePath(path), file);
7073
}
7174
}
7275

0 commit comments

Comments
 (0)