Try if you get a more descriptive error message by running the test from the terminal, like this:
ng test -sm=false
In your test, you can replace
it('should...')
with
fit('should...')
Now only tests preceded by fit will run.
To leave the browser open after running the test, run the test like this:
ng test -sm=false --single-run false
Personally, I have encountered this error twice. Both were only triggered when calling fixture.detectChanges().
The first time, I solved it by using string interpolation more safely in my .html file.
Unsafe example:
<p>{{user.firstName}}</p>
Safe(r) example (note the question mark):
<p>{{user?.firstName}}</p>
The same may apply to property binding:
<p [innerText]="user?.firstName"></p>
The second time, I was using a DatePipe in my .html file, but the mock property that I used it on was not a date.
.html file:
<p>{{startDate | date: 'dd-MM-yyyy'}}</p>
.ts (mock-data) file (wrong):
let startDate = 'blablah';
.ts (mock-data) file (correct):
let startDate = '2018-01-26';
[object ErrorEvent] thrown
is literally all it says. There is nothing before or after. – Stuntit()
tofit()
, even though only that single test is running, the error is still being thrown. Any debug recommendations for this type of error? – Amitosis