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
Date object in stub.withArgs
is not working as expected
#1865
Comments
@mrkesh "worked previously" is a bit vague. Could you use |
@mroderick , do you mean the actual commit that broke the it? The test created above passed with |
He means the actual commit, yes. |
Ok, used
I used the test above to for verification. |
👋 FYI here's why this happens:
Thus the two dates are returned as equal and we retrieve the first fake (the first I would do a PR but i'm not too sure what you'd like to do to fix this. |
Hello everyone! I run into the similar issue recently: const sinon = require('sinon')
const assert = require('assert')
const stub = sinon.stub()
const d1 = new Date('2000-01-01')
const d2 = new Date('2001-01-01')
stub(d1)
assert(stub.calledWith(d1) === true)
assert(stub.calledWith(d2) === false) When I explored the code I ended up with the same result as @43081j did. 014aecf might be a potential source of the issue. |
Describe the bug
Setting up multiple return values for a stub method with
Date
objects as argument always returns the last value.Sample code
Expected behavior
Calling foo.bar(d1) should yield 100. Regardless of the setup, the stub will always return 101, the last return value set for the
bar
stub method. Usingsinon.match.same
works though.Library version
Started failing from
6.1.3
. Worked previously.The text was updated successfully, but these errors were encountered: