X Tutup
Skip to content

TestComponentBuilder/inject does not work, when component has templateUrl #5662

@uebelack

Description

@uebelack

Following test fails as expected (http://plnkr.co/edit/61ByTt?p=preview):

@Component({
  selector: 'header',
  template: '<h1>Hello Welt!</h1>'
})
export class TestComponent2 {
 }

describe('TestComponent', () => {
  it('should fail', inject([TestComponentBuilder], (tcb) => {
    return tcb.createAsync(TestComponent2).then((fixture) => {
      fixture.detectChanges();
      expect(1).toEqual(2);
    });
  }));
)};

Moving the template to an external resource, the test passes without failing (the async part doesn't get executed) (http://plnkr.co/edit/ZOeFTO?p=preview):

@Component({
  selector: 'header',
  templateUrl: 'src/test.html'
})
export class TestComponent {

}

describe('TestComponent', () => {
  it('should fail', inject([TestComponentBuilder], (tcb) => {
    return tcb.createAsync(TestComponent).then((fixture) => {
      fixture.detectChanges();
      expect(1).toEqual(2);
    });
  }));
)};

Metadata

Metadata

Assignees

Labels

area: testingIssues related to Angular testing features, such as TestBedhotlist: components teamRelated to Angular CDK or Angular Material

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    X Tutup