mardi 5 juin 2018

zone.js:192 Uncaught Error:

I need to test this function:

  getallalarmstype() {
    this.service.AlarmTypeGetAll().subscribe(
      alarmstype => {
        this.alarmstype = alarmstype;
      }
    );
  }

I tried this script that show me this error:

  it('should call service', done => {
        const mocking = [ {id: 1, desc: 'description', prodnum: 2}];
        component['service'].AlarmTypeGetAll().subscribe(alarmstype => {
            expect(component.alarmstype).toBe(mocking );
            expect(component['service'].AlarmTypeGetAll).toHaveBeenCalled();
            done();
        });
        component.getallalarmstype();
    })

Please, can you ask me how to solve this error?

Thnx

Aucun commentaire:

Enregistrer un commentaire