3

I'm launching some tests in Angular 7, with karma (4.0.1) and jasmine (2.8.0). The problem is that tests always failed in my computer wheras in another no. The error is : Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL. I made lof of searches in stackoverflow and elsewhere but it doesn't work yet.

I have already modified some values in karma.conf.js like browserDisconnectTimeout, browserDisconnectTolerance, browserNoActivityTimeout but anything. 

import {async, TestBed} from '@angular/core/testing';
import {RouterTestingModule} from '@angular/router/testing';
import {AppComponent} from './app.component';
import {LayoutsModule} from './layouts/layouts.module';
import {HttpClientTestingModule} from '@angular/common/http/testing';
import {ToastrModule} from 'ngx-toastr';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';

describe('AppComponent', () => {
  beforeEach(async(() => {
    TestBed.configureTestingModule({
      imports: [
        RouterTestingModule, LayoutsModule, HttpClientTestingModule, BrowserAnimationsModule, ToastrModule.forRoot()
      ],
      declarations: [
        AppComponent
      ],
    }).compileComponents();
  }));

  it('should create the app', () => {
    const fixture = TestBed.createComponent(AppComponent);
    const app = fixture.debugElement.componentInstance;
    expect(app).toBeTruthy();
  });

  it(`should have as title 'sfr-fr'`, () => {
    const fixture = TestBed.createComponent(AppComponent);
    const app = fixture.debugElement.componentInstance;
    expect(app.title).toEqual('sfr-fr');
  });

  it('should render a wrapper div', () => {
    const fixture = TestBed.createComponent(AppComponent);
    fixture.detectChanges();
    const compiled = fixture.debugElement.nativeElement;
    expect(compiled.querySelector('.wrapper')).toBeDefined();
  });
});
1
  • Did you solve this, I'm getting the same issue switching from ChromeHeadless to PhantomJS for CI deployment. Commented Jul 29, 2019 at 7:11

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.