Closed tbiesemann closed 3 years ago
Calling sinon.assert.calledWith fails, if the stub was called with an object having a toString method which throws.
How to reproduce
it('shall reproduce formatio bug', function () { const poison = { toString: () => { throw new Error("Boom"); } }; const myStub = sinon.stub(); myStub(poison); sinon.assert.calledWith(myStub, "42"); });
Expectation is to see a sinon error message like "expected stub to be called with..." instead of a formatio error.
I think a try/catch and swallow the error should be sufficient.
Edit: enable syntax highlighting
This package has been deprecated in favour of using util.inspet in the Sinon projects
util.inspet
Calling sinon.assert.calledWith fails, if the stub was called with an object having a toString method which throws.
How to reproduce
Expectation is to see a sinon error message like "expected stub to be called with..." instead of a formatio error.
I think a try/catch and swallow the error should be sufficient.