Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sinon-chai ignoring the lastCall property on spy #94

Closed
Kilometers42 opened this issue Apr 3, 2017 · 1 comment
Closed

Sinon-chai ignoring the lastCall property on spy #94

Kilometers42 opened this issue Apr 3, 2017 · 1 comment

Comments

@Kilometers42
Copy link

It looks like sinon-chai is ignoring lastCall property on a spy inside an expect. For example:
expect(spy.lastCall).to.have.been.calledWith(argUsedOnLastCall)
sinon-chai ignores the lastCall property and does the same thing that it would do with this line:
expect(spy).to.have.been.calledWith(argUsedOnLastCall)
where it checks argUsedOnLastCall against all the calls that have been made with that spy. However, if you were to do this in pure sinon it behaves correctly: sinon.assert.calledWith(lastCall, argUsedOnLastCall) and checks argUsedOnLastCall only against the last call of the spy.

@domenic
Copy link
Collaborator

domenic commented May 1, 2017

Cannot reproduce:

"use strict";

const sinon = require("sinon");
const chai = require("chai");

const expect = chai.expect;
chai.should();

const sinonChai = require("sinon-chai");
chai.use(sinonChai);

const spy = sinon.spy();

spy(1, 2, 3);
spy(4, 5, 6);


expect(() => spy.lastCall.should.have.been.calledWith(4, 5, 6)).to.not.throw()

Will close for now, but happy to reopen if you can provide a repro case like this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants