Skip to content

Commit 739f99c

Browse files
crisbetoandrewseguin
authored andcommitted
build: fix runtime errors not being logged out on karma initialization (#9888)
Currently if something throws an error right after Karma has initialized, the log will look something like the following: ``` HeadlessChrome 0.0.0 (Windows 10 0.0.0) ERROR { "originalErr": {}, "__zone_symbol__currentTask": { "type": "microTask", "state": "notScheduled", "source": "Promise.then", "zone": "<root>", "cancelFn": null, "runCount": 0 } } ``` These changes log out the stack trace explicitly so we have some more info to work with if it happens.
1 parent b9856b7 commit 739f99c

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

test/karma-test-shim.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,15 @@ System.config({
116116
});
117117

118118
// Configure the Angular test bed and run all specs once configured.
119-
configureTestBed()
119+
configureTestBed()
120120
.then(runMaterialSpecs)
121-
.then(__karma__.start, __karma__.error);
121+
.then(__karma__.start, function(error) {
122+
// Passing in the error object directly to Karma won't log out the stack trace and
123+
// passing the `originalErr` doesn't work correctly either. We have to log out the
124+
// stack trace so we can actually debug errors before the tests have started.
125+
console.error(error.originalErr.stack);
126+
__karma__.error(error);
127+
});
122128

123129

124130
/** Runs the Angular Material specs in Karma. */

0 commit comments

Comments
 (0)