Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/32.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 5:Firefox上的单元测试失败_Angular_Unit Testing_Firefox - Fatal编程技术网

Angular 5:Firefox上的单元测试失败

Angular 5:Firefox上的单元测试失败,angular,unit-testing,firefox,Angular,Unit Testing,Firefox,我用Karma和Jasmine为Angular 5组件编写测试。测试正在Chrome和Firefox上运行(karma Chrome launcher v2.1.1和karma Firefox launcher v1.1.0) 在Chrome上,所有测试都成功,但对于Firefox,出现了一个奇怪的错误:[object ErrorEvent]抛出 Firefox 58.0.0 (Mac OS X 10.12.0) Component: Login should redirect if user

我用Karma和Jasmine为Angular 5组件编写测试。测试正在Chrome和Firefox上运行(karma Chrome launcher v2.1.1和karma Firefox launcher v1.1.0)

在Chrome上,所有测试都成功,但对于Firefox,出现了一个奇怪的错误:
[object ErrorEvent]抛出

Firefox 58.0.0 (Mac OS X 10.12.0) Component: Login should redirect if user click Forgot password button FAILED
        [object ErrorEvent] thrown
Firefox 58.0.0 (Mac OS X 10.12.0): Executed 33 of 43 (1 FAILED) (skipped 6) (0 secs / 10.761 secs)
Chrome 64.0.3282 (Mac OS X 10.12.6): Executed 33 of 43 (skipped 6) SUCCESS (0 secs / 5.868 secs)
Firefox 58.0.0 (Mac OS X 10.12.0) Component: Login should redirect if user click Forgot password button FAILED
        [object ErrorEvent] thrown
Firefox 58.0.0 (Mac OS X 10.12.0): Executed 37 of 43 (1 FAILED) (skipped 6) (13.172 secs / 12.945 secs)
Chrome 64.0.3282 (Mac OS X 10.12.6): Executed 37 of 43 (skipped 6) SUCCESS (7.108 secs / 6.964 secs)
如果用户单击忘记密码按钮,测试应重定向:

如果我单独运行这个测试,那么一切正常

当我使用
fakeAsync
包含一个测试时,问题就开始了。如果我删除这个测试,那么一切都正常工作

有没有人遇到过类似的问题,或者我做错了什么? 谢谢

  it('should redirect if user click Forgot password button', inject([UserService], (userService: UserService) => {
    // GIVEN
    spyOn(userService, 'goToLogin');

    // WHEN
    component.goToForgotPassword();

    // THEN
    expect(userService.goToLogin).toHaveBeenCalledWith(Constants.AUTH_PAGES.FORGOT_PASSWORD);
  }));