Angular Tests failed with : "Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL "

Viewed 270

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();
  });
});
0 Answers
Related