Skip to content

Commit 8e5b83b

Browse files
clydinalan-agius4
authored andcommitted
test(@angular-devkit/build-angular): avoid crashing during test failure in utility function
Previously, if a browser build failed using the `browserBuild` test utility function, the test utility would try to access properties that did not exist and would crash. This increased the complexity to debug failing tests. With the new behavior, the `browserBuild` test utility will return with an empty `files` object and the failed builder result.
1 parent 2327ddc commit 8e5b83b

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

packages/angular_devkit/build_angular/src/test-utils.ts

+9
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,15 @@ export async function browserBuild(
8181
const output = (await run.result) as BrowserBuilderOutput;
8282
expect(output.success).toBe(true);
8383

84+
if (!output.success) {
85+
await run.stop();
86+
87+
return {
88+
output,
89+
files: {},
90+
};
91+
}
92+
8493
expect(output.outputPaths[0]).not.toBeUndefined();
8594
const outputPath = normalize(output.outputPaths[0]);
8695

0 commit comments

Comments
 (0)