-
Notifications
You must be signed in to change notification settings - Fork 117
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Better error output for toHaveBeenCalledWith #60
Comments
Hey @ericclemmons! Thanks for the input. I'm not sure if you saw #48 or not, but it seems you're not the only one who wants better error messages from Re: only referencing the last call - I think that makes a lot of sense. I can't think of any real scenario where I call a method more than once and then want to assert that one of the calls had a certain set of args. I'd be fine with making that the default behavior. One big upside is that by simplifying we can avoid printing the arguments that were used in multiple calls, which is nice. And we can use the same mechanism as Yes, this would be a breaking change. But I'm ok with that. We've been on 1.x for a while now, and this behavior is subtle enough that I doubt it'll break many people's tests. |
I'd say let's get a new PR going. You want to take a shot @ericclemmons? |
@mjackson I'll take a stab at it. Thanks for being so receptive! |
Taking a stab at this today, but wanted to OK having a separate Rational being, from a cursory inspection, If you'd prefer I not do this, I'll bake the tests into Let me know, thanks! |
Ya, a separate file would be great.
|
I'm...gonna have to put a pin in this or open a neighboring issue in my fork. Currently deadlocked getting tests going:
I'll check on this again tomorrow... |
Hmm, looks like you already have an instance of Karma running. It may be confused. |
Hi, thanks for the great library, wondering if a fix for this issue is on the horizon? |
If there were a way to run the tests purely in Node (and let CI do the integration tests), I could pick this back up. Me thinks that it doesn't like that I have both Chrome & Chrome Canary, but I also haven't used Karma since my despicable Angular 1 days :) |
fwiw, I have both Chrome stable and canary installed and |
Can you take over this then? |
@ericclemmons could you link me to the PR you have in progress (or create one if there isn't one yet)? |
Your proposal looks good. I have been using expect my branch and it serving me good. Although I agree that most times we want to see only last call, I would like to see a clear information that it is checking only the last call. Perhaps even a different name e.g. I have updated #48 so that it is in sync with master and linting passes. I've been using expect from this branch for a while. (did not test after merging master). |
First, great project! I'm sure you saw my tweet of praise:
toHaveBeenCalledWith
Anyway, having replaced
sinon
with this, I've noticed that this very readable call......yields an error with only half of the picture. There's no telling what it was called with, or never called at all:
toEqual
However, explicitly using
toEqual
is much more useful:Proposal
I'd recommend mimicking the output of
toEqual
.When the spy was called & matched.
No changes.
(Patch) When the spy was never called.
(Patch) Show all calls.
(Breaking Feature) Expect the assertion to always reference the last call (e.g.
spy.calls[spy.calls.length -1]
.This is a suggestion for a possible future release that's largely unrelated to this issue.
What I like about this approach is that it works great for repeated assertions:
I only list it here because improving the usability of
toHaveBeenCalledWith
will lend itself to more use :)What do you think @mjackson?
The text was updated successfully, but these errors were encountered: