chaijs / sinon-chai

Extends Chai with assertions for the Sinon.JS mocking framework.
Other
1.09k stars 108 forks source link

Doesn't work on stubs #35

Closed ianmurrays closed 10 years ago

ianmurrays commented 10 years ago

Stub objects work exactly as spy objects according to SinonJS' documentation, but sinon-chai matchers don't work on stubs, only spies.

The following doesn't work:

it('should call Something with the username and password', sinon.test(function () {
  this.stub(Something, ',method').returns({then: angular.noop});

  var username = 'username',
      password = 'password';

  Authentication.authenticate(username, password);

  expect(Something.request).to.have.been.calledWith(sinon.match.any, sinon.match({
    username: username,
    password: password
  }));
}));

But anything with spies does.

ianmurrays commented 10 years ago

I was loading sinon and chai independently before sinon-chai in my karma runner. Working good now. Thanks!