Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

angular - Karma Start Fails - HeadlessChrome - ERROR Uncaught [object Object]

I am using Karma to run test on my Angular 4 app. It works locally but when it runs on my host environment (Travis CI) it fails with the following information:

INFO [HeadlessChrome 0.0.0 (Ubuntu 0.0.0)]: Connected on socket vT0QnQaqRkn010dfsw with id 10189531

HeadlessChrome 0.0.0 (Ubuntu 0.0.0): Executed 0 of 180 SUCCESS (0 secs / 0 secs)

e 0.0.0 (Ubuntu 0.0.0): Executed 1 of 180 SUCCESS (0 secs / 0.714 secs)

HeadlessChrome 0.0.0 (Ubuntu 0.0.0) ERROR

  Uncaught [object Object]

  at http://localhost:9876/_karma_webpack_/vendor.bundle.js:14078

I tried following the suggestions (deleting NPM cache, etc) from "Uncaught [object Object]" when running karma tests on Angular but it did not solve my issue.

How can I identify what is causing this Uncaught [object Object] error. What additional steps should I take to troubleshoot?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

This is what fixed it for me:

I searched the whole project for occurrences of HttpClientModule in all *.spec.ts files. Turned out I had a few!

Then I replaced all occurrences of

import { HttpClientModule } from '@angular/common/http';

with

import { HttpClientTestingModule } from '@angular/common/http/testing';

And then I made sure that the entry in the imports array of each of my test's TestBed.configureTestingModule was changed from HttpClientModule to HttpClientTestingModule.

And finally I turned my Wifi off and ran the tests again. And voilà: It worketh!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...