-
-
Notifications
You must be signed in to change notification settings - Fork 772
Closed
Description
- Sinon version : 4.1.3
- Environment : Ubuntu
Code for formatting assertion error messages does not properly account for non-string method names (i.e. symbols). This may be a regression of #1002.
Reproduction Steps
Running this bit of code:
const sinon = require('sinon');
const sym = Symbol('my symbol');
const obj = { [sym]: (a, b) => a + b };
const spy = sinon.spy(obj, sym)
sinon.assert.calledWith(spy, 1, 2);
Results in this error:
TypeError: Cannot convert a Symbol value to a string
at String.replace (<anonymous>)
at Function.printf (/path/to/node_modules/sinon/lib/sinon/spy.js:375:31)
at Object.assert.(anonymous function) [as calledWith] (/path/to/node_modules/sinon/lib/sinon/assert.js:80:68)
Instead of the expected AssertError: expected Symbol(my symbol) to be called with arguments
.
Possible fix would be to explicitly type-cast symbol to string at
Line 379 in 5e131b3
return formatter.call(null, spyInstance, args); |
return String(formatter.call(null, spyInstance, args))
)fatso83
Metadata
Metadata
Assignees
Labels
No labels