lundi 5 février 2018

How to add forms to test in angular 5

I created an app in angular 5. Now I want to add some tests.

At the moment almost all the specs are failing even though I didnt even add anything.

For my first component it says: Can't bind to 'formGroup' since it isn't a known property of 'form'.

How do i inject the necessary dependencys in the component?

Right now I have this:

  beforeEach(async(() => {
    TestBed.configureTestingModule({
      declarations: [ LoginComponent ],
      providers: [{
        provide: Router,
        useClass: class { navigate = jasmine.createSpy("navigate"); }
      }, AuthentificationService, NotificationService, FormBuilder]
    })
    .compileComponents();
  }));

This is the constructor of the component:

 constructor(private router: Router, private auth: AuthentificationService, private ns: NotificationService, private fb: FormBuilder) {}

Aucun commentaire:

Enregistrer un commentaire