-
-
Notifications
You must be signed in to change notification settings - Fork 779
Open
Labels
Description
Describe the bug
similar to #2677 , looks like deep equal behavior has regressed in sinon 21.0.2.
comparing stub arguments succeeds for native variables, but fails for object.
in this case, mongo sequence comparison.
To Reproduce
use the following two tests, both succeeed with sinon 21.0.1, however the first one fails in sinon 21.0.2:
describe.only('test sinon object comparison', () => {
class TestDao {
getRawObjects ({ param1, param2, seq, limit, sort }) {
const q = { param1, param2 }
if (seq) {
q.seq = { $gt: new Mongo.ObjectId(seq) }
}
this.getObjects(q, limit, sort)
}
getObjects (query, limit, sort) {
// do something
}
}
it('compares objects with sinon.assert, including mongo ObjectId conversion', () => {
const query = { param1: 'str', param2: 'foo', seq: '5feb913181428ef0bb81524a' }
const expectedQuery = {
param1: 'str',
param2: 'foo',
seq: { $gt: new Mongo.ObjectId(query.seq) }
}
const instance = new TestDao()
sinon.stub(instance, 'getObjects').resolves([])
instance.getRawObjects({ ...query, limit: 100, sort: { sort: 'desc' } })
sinon.assert.calledOnceWithExactly(instance.getObjects, expectedQuery, 100, { sort: 'desc' })
})
it('compares objects with sinon.assert', () => {
const query = { param1: 'str', param2: 'foo' }
const expectedQuery = {
param1: 'str',
param2: 'foo'
}
const instance = new TestDao()
sinon.stub(instance, 'getObjects').resolves([])
instance.getRawObjects({ ...query, limit: 100, sort: { sort: 'desc' } })
sinon.assert.calledOnceWithExactly(instance.getObjects, expectedQuery, 100, { sort: 'desc' })
})
})
Expected behavior
both tests should succeed.
Screenshots
N/A
Context (please complete the following information):
- Sinon version : 21.0.2
- Runtime:
Binaries:
Node: 24.13.1 - /usr/local/bin/node
npm: 11.8.0 - /usr/local/bin/npm
Browsers:
Chrome: 145.0.7632.160
Safari: 26.1
Reactions are currently unavailable