Skip to content

Commit c3b8465

Browse files
crisbetojelbourn
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 7feaeb1 commit c3b8465

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
@@ -117,9 +117,15 @@ System.config({
117117
});
118118

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

124130

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

0 commit comments

Comments
 (0)