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

后端 未结 4 734
不知归路
不知归路 2020-12-15 06:49

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 informati

4条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-15 07:44

    Full disclosure, I'm the guy that fixed this problem with Justin.

    The problem is that we were importing modules into our unit tests. These modules have a component that has ngOnInit which makes an HTTP request. The module injects the real component into the test and it tries to make its HTTP request but fails. Because it's out of the normal stack, the stack trace gives us the very unhelpful error Uncaught [object Object].

    In order to avoid that problem and for the component to not be undefined we use Christian Nunciato's helpful ng2-mock-component library to make a mock component that takes all the same inputs.

    Because the mocked component has its own unit tests, we don't care if the unit tests on the parent component don't test the child at the same time.

提交回复
热议问题