Skip to content

Commit 88d3c3c

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. (cherry picked from commit 8e5b83b)
1 parent 000d47a commit 88d3c3c

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

Lines changed: 9 additions & 0 deletions
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)