Skip to content

Commit d657609

Browse files
committed
test(@angular/build): reset project metadata before each run
Prevents test flakiness caused by `useProject` not cleaning up metadata between runs.
1 parent 8c95e8e commit d657609

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

modules/testing/builder/src/builder-harness.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,10 @@ export class BuilderHarness<T> {
115115
return join(getSystemPath(this.host.root()), path);
116116
}
117117

118+
resetProjectMetadata(): void {
119+
this.projectMetadata = DEFAULT_PROJECT_METADATA;
120+
}
121+
118122
useProject(name: string, metadata: Record<string, unknown> = {}): this {
119123
if (!name) {
120124
throw new Error('Project name cannot be an empty string.');

modules/testing/builder/src/jasmine-helpers.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,11 @@ export function describeBuilder<T>(
3737
});
3838

3939
describe(options.name || builderHandler.name, () => {
40-
beforeEach(() => host.initialize().toPromise());
40+
beforeEach(async () => {
41+
harness.resetProjectMetadata();
42+
43+
await host.initialize().toPromise();
44+
});
4145

4246
afterEach(() => host.restore().toPromise());
4347

0 commit comments

Comments
 (0)