lundi 28 septembre 2015

Chai-spies: AssertionError: expected { Spy }

I am using chai-spies to make sure a function in my controller is invoked, here's my test:

it('Should show right season and analysts when competition has been selected', function (done) {
    scope.selectedCompetition = scope.competitions[3];
    var spy = chai.spy(scope.selectedCompetitionChanged);
    scope.selectedCompetitionChanged();
    expect(spy).to.have.been.called();
    done();
  });

where scope.selectedCompetitionChanged is a function. The test fails with the following error:

 AssertionError: expected { Spy } to have been called
        at Context.<anonymous> (base/tests/client/controllers/prediction.js?02f216981852d0775780926989e7266c6afb0af6:61:30)

How come this happen if I invoke explicitly call the function? Thanks

Aucun commentaire:

Enregistrer un commentaire