mercredi 6 avril 2016

Angular 2 Component test error: Cannot resolve all parameters for 'TestComponentBuilder'

I am trying to do Angular 2.0 Component tests. I was using this post as a reference (no reference in Angular 2.0 dos, yet).

This is my test:

import 'reflect-metadata';
import {
  it,
  describe,
  expect,
  inject,
  injectAsync,
  beforeEach,
  beforeEachProviders,
  TestComponentBuilder,
  ComponentFixture
} from 'angular2/testing';
import {Main} from './index';

describe('Main', () => {

  // provide our implementations or mocks to the dependency injector
  beforeEachProviders(() => [
    Main
  ]);

  it('should have title', inject([ Main ], (main) => {
    expect(main.title).toEqual('Hello Angular 2.0');
  }));

  it('should add item to list', injectAsync([TestComponentBuilder, Main], (tcb: TestComponentBuilder, main) => {
    return tcb.createAsync(Main).then((componentFixture: ComponentFixture) => {
      const element = componentFixture.nativeElement;
      expect(element.querySelectorAll('input').length).toBe(1);
    });
  }));
})

Now, I am getting an Cannot resolve all parameters for 'TestComponentBuilder' error when running those tests. Trying to add TestComponentBuilder to the beforeEachProviders results with a different error:

Cannot resolve all parameters for 'TestComponentBuilder'(?).

What am I doing wrong?

Aucun commentaire:

Enregistrer un commentaire