angular: Error: Cannot make XHRs from within a fake async test.

Steps to reproduce and a minimal demo of the problem

What steps should we try in your demo to see the problem?

export function setupComponentFakeAsync(type:any, continuation:Function) {
    return fakeAsync(inject([TestComponentBuilder], (tcb:TestComponentBuilder) => {
        let fixture:ComponentFixture = null;
        tcb.createAsync(type).then((f:ComponentFixture) => fixture = f);
        tick(50);
        fixture.detectChanges();
        continuation(fixture);
    }));
}


it('shows an empty origin station text field in the default component state',
    setupComponentFakeAsync(SearchComponent, (fixture:ComponentFixture) => {
        let input:any = fixture.nativeElement.querySelector('#fromStation');

        expect(input.value).toBe('');
    })
);



**Current behavior**
Exception:

> Error: Cannot make XHRs from within a fake async test. in d:/Users/l026291/Development/ts-automat-fe/node_modules/zone.js/dist/fake-async-test.js (line 248)
    onScheduleTask@d:/Users/l026291/Development/ts-automat-fe/node_modules/zone.js/dist/fake-async-test.js:248:96
    scheduleTask@d:/Users/l026291/Development/ts-automat-fe/node_modules/angular2/bundles/angular2-polyfills.js:359:64
    scheduleMacroTask@d:/Users/l026291/Development/ts-automat-fe/node_modules/angular2/bundles/angular2-polyfills.js:299:52
    d:/Users/l026291/Development/ts-automat-fe/node_modules/angular2/bundles/angular2-polyfills.js:148:39
    send

**Expected/desired behavior**
The test is working just as with beta 15.

**Other information**

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 9
  • Comments: 21 (8 by maintainers)

Most upvoted comments

+1