Commit 56b0612
authored
Check call count type (#2410)
* Strip stack frames in `this.message`
This saves us from having to do it every time, and makes things much
nicer. Also use a little bit more specific regex, to avoid issues with
messages that happen to contain the word "at"
* Check type of callCount argument and error accordingly
This is to fixes #2408, which could result in error messages like
"expected spy to be called 10 times but was called 10 times".
Now we will instead say "expected '10' to be a number, but was of type
string", which is much clearer!
* A little more explanatory comment
* Edit the comment about appending stack frames
What's actually happening here is that we want to add a frame of context
to `callStr`, but the first two stack frames will be within Sinon code
and thus probably not helpful to the end-user.
So, we skip the first two stack frames, and append the third stack
frame, which should contain a meaningful location to the end-user.
* Add test for adding stack traces to error message
This ensures that if at some point we end up with another Sinon layer in
the stack at some point, we'll catch it and hopefully adjust accordingly
For reference, as of this commit, the Sinon portion of the stack is:
lib/sinon/proxy-invoke.js:65:15
lib/sinon/proxy.js:265:26
Also convert a neighboring test to async while we're at it1 parent 7863e2d commit 56b0612
4 files changed
Lines changed: 89 additions & 161 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
159 | 159 | | |
160 | 160 | | |
161 | 161 | | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
166 | 172 | | |
167 | 173 | | |
168 | 174 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
220 | 220 | | |
221 | 221 | | |
222 | 222 | | |
223 | | - | |
| 223 | + | |
| 224 | + | |
224 | 225 | | |
225 | 226 | | |
226 | 227 | | |
| |||
0 commit comments