X Tutup
Skip to content

Components with templateUrl can mess up injectAsync automatic async tracking #6359

@juliemr

Description

@juliemr

This came up in material2 tests.

The testing zone that angular2/testing uses for determining async behavior seems to ignore XHR requests. This means that components with a templateUrl can cause tests to exit early.

Example:

@Component({
  selector: 'my-comp',
  template: `<span>Hello</span>`,
})
class TemplateComp {
}

@Component({
  selector: 'my-comp',
  templateUrl: '/foo/bar'
})
class TemplateUrlComp {
}

    // GOOD: this one correctly fails
    it('should fail here 2',
        injectAsync([], () => {
          return builder.createAsync(TemplateComp).then((fixture) => {
            expect(11).toBe(22);
          });
        }));

    // BAD: this one DOES NOT fail
    it('should fail here 2',
        injectAsync([], () => {
          return builder.createAsync(TemplateUrlComp).then((fixture) => {
            expect(33).toBe(44);
          });
        }));

cc @jelbourn

Metadata

Metadata

Assignees

Labels

area: testingIssues related to Angular testing features, such as TestBedtype: bug/fix

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    X Tutup