Closed ziluvatar closed 1 year ago
Patch coverage: 100.00
% and no project coverage change.
Comparison is base (
45be60f
) 95.95% compared to head (95576e2
) 95.95%.:exclamation: Current head 95576e2 differs from pull request most recent head 4aab223. Consider uploading reports for the commit 4aab223 to get more accurate results
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.
This is great and works just like the rest. Thanks!
published as sinon 15.0.2
Purpose (TL;DR) - mandatory
Fixes https://github.com/sinonjs/sinon/issues/2496 by cleaning any previous
exception*
behavior whencallsFake
is used.Background (Problem in detail)
Precedence among behaviors is defined by the behavior itself (cleaning other previously set behaviors) and by the order at invocation time.
Since
throws
behavior (exception
andexceptionHandler
) is the first one to run at invocation time, other behaviors can only define precedence on its own definition. That's why I modifiedcallsFake
behavior to cleanthrows
Solution
When
callsFake
is chained on a stub it cleans previousexception
andexceptionHandler
values which essentially invalidates any previousthrows
orthrowsException
behaviours.Note: I think this fix should not break any current usage, because any attempt to run the stubbed function would have raised an exception already and the developer would have noticed the same I did notice: callsFake was ignored, so that, probably they applied some workaround like restoring + callsFake OR recreating the stub + callsFake.
How to verify - mandatory
Run:
You should see:
Checklist for author
npm run lint
passes