Error: Timeout - Async callback was not invoked within 30000ms (set by jasmine.DEFAULT_TIMEOUT_INTERVAL)
Error: Timeout - Async callback was not invoked within 30000ms (set by jasmine.DEFAULT_TIMEOUT_INTERVAL)
无论我做了什么,仍然无法正确地进行测试运行。尽管通过所有其他帖子我尝试了所有可能的解决方案,但仍然无效。
通过设置 jasmine.DEFAULT_TIMEOUT_INTERVAL = 30000;
我认为它会起作用但没有成功。
任何想法如何解决这个问题?
describe('DashboardComponent', () => {
let component: DashboardComponent;
let fixture: ComponentFixture<DashboardComponent>;
let therapistStatus = TherapistStatus;
let id = '';
let firstName = '';
let lastName = '';
let email = '';
let status = 2;
let statusChanges = '';
let therapist = new Therapist({id, firstName, lastName, email, status, statusChanges});
beforeEach(async(() => {
jasmine.DEFAULT_TIMEOUT_INTERVAL = 30000;
TestBed.configureTestingModule({
declarations: [ DashboardComponent],
schemas: [NO_ERRORS_SCHEMA],
imports: [
RouterTestingModule,
FormsModule,
OAuthModule.forRoot(),
ToastrModule.forRoot(),
HttpClientTestingModule,
ReactiveFormsModule,
TranslateModule.forRoot()
],
providers: [UserService]
})
.compileComponents().then(() => {
fixture = TestBed.createComponent(DashboardComponent);
component = fixture.componentInstance;
});
}));
beforeEach(() => {
fixture = TestBed.createComponent(DashboardComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create the dashboard component', () => {
expect(component).toBeTruthy();
});
您不需要使模块实例化异步。尝试按以下方式删除和修改您的代码(请检查括号是否遗漏)。希望这有帮助。
describe('DashboardComponent', () => {
let component: DashboardComponent;
let fixture: ComponentFixture<DashboardComponent>;
let therapistStatus = TherapistStatus;
let id = '';
let firstName = '';
let lastName = '';
let email = '';
let status = 2;
let statusChanges = '';
let therapist = new Therapist({id, firstName, lastName, email, status, statusChanges});
beforeEach(() => {
jasmine.DEFAULT_TIMEOUT_INTERVAL = 30000;
TestBed.configureTestingModule({
declarations: [ DashboardComponent],
schemas: [NO_ERRORS_SCHEMA],
imports: [
RouterTestingModule,
FormsModule,
OAuthModule.forRoot(),
ToastrModule.forRoot(),
HttpClientTestingModule,
ReactiveFormsModule,
TranslateModule.forRoot()
],
providers: [UserService]
}).compileComponents();
fixture = TestBed.createComponent(DashboardComponent);
component = fixture.componentInstance;
});
beforeEach(() => {
fixture = TestBed.createComponent(DashboardComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create the dashboard component', () => {
expect(component).toBeTruthy();
});
无论我做了什么,仍然无法正确地进行测试运行。尽管通过所有其他帖子我尝试了所有可能的解决方案,但仍然无效。
通过设置 jasmine.DEFAULT_TIMEOUT_INTERVAL = 30000;
我认为它会起作用但没有成功。
任何想法如何解决这个问题?
describe('DashboardComponent', () => {
let component: DashboardComponent;
let fixture: ComponentFixture<DashboardComponent>;
let therapistStatus = TherapistStatus;
let id = '';
let firstName = '';
let lastName = '';
let email = '';
let status = 2;
let statusChanges = '';
let therapist = new Therapist({id, firstName, lastName, email, status, statusChanges});
beforeEach(async(() => {
jasmine.DEFAULT_TIMEOUT_INTERVAL = 30000;
TestBed.configureTestingModule({
declarations: [ DashboardComponent],
schemas: [NO_ERRORS_SCHEMA],
imports: [
RouterTestingModule,
FormsModule,
OAuthModule.forRoot(),
ToastrModule.forRoot(),
HttpClientTestingModule,
ReactiveFormsModule,
TranslateModule.forRoot()
],
providers: [UserService]
})
.compileComponents().then(() => {
fixture = TestBed.createComponent(DashboardComponent);
component = fixture.componentInstance;
});
}));
beforeEach(() => {
fixture = TestBed.createComponent(DashboardComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create the dashboard component', () => {
expect(component).toBeTruthy();
});
您不需要使模块实例化异步。尝试按以下方式删除和修改您的代码(请检查括号是否遗漏)。希望这有帮助。
describe('DashboardComponent', () => {
let component: DashboardComponent;
let fixture: ComponentFixture<DashboardComponent>;
let therapistStatus = TherapistStatus;
let id = '';
let firstName = '';
let lastName = '';
let email = '';
let status = 2;
let statusChanges = '';
let therapist = new Therapist({id, firstName, lastName, email, status, statusChanges});
beforeEach(() => {
jasmine.DEFAULT_TIMEOUT_INTERVAL = 30000;
TestBed.configureTestingModule({
declarations: [ DashboardComponent],
schemas: [NO_ERRORS_SCHEMA],
imports: [
RouterTestingModule,
FormsModule,
OAuthModule.forRoot(),
ToastrModule.forRoot(),
HttpClientTestingModule,
ReactiveFormsModule,
TranslateModule.forRoot()
],
providers: [UserService]
}).compileComponents();
fixture = TestBed.createComponent(DashboardComponent);
component = fixture.componentInstance;
});
beforeEach(() => {
fixture = TestBed.createComponent(DashboardComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create the dashboard component', () => {
expect(component).toBeTruthy();
});