-
Notifications
You must be signed in to change notification settings - Fork 142
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
Shortcut for new stub returning args #187
Comments
I don't really understand this proposed API. How would you specify args and matchers in the stubbing? |
Arguments and matches are put directly to new shortcut fn. In this case
|
I don't understand, how would an implementation of |
(btw, |
Ohh sorry for that |
Hmm, ok. So that yields the next question: how do people set |
I did not think of them, would probably let you use full format when you need |
Ok, I understand the proposal now. I'm pretty conservative in keeping the surface area of the test double API distinct. Since it's an opinionated library, I generally only want there to be one way to do something unless there's a tremendous advantage to providing a shortcut. Because the variability in stubbing & verifying is, frankly, enormous, any synonyms or shortcuts risk confusing people even more as they try to learn an already confusing API. I am especially reticent to add new top-level methods to the I don't think this proposed API adds enough benefit to outweigh those documentation and confusion risks. When I look at Sinon, with its several ways to create the same stubbing, the numerous bugs they encounter when an option works in one stubbing style but not another is a real problem that I am careful to avoid here. I'd recommend defining this helper yourself with something like: whenFn = function (args...) {
return function (stubbings...) {
return td.when(td.func()(...args)).thenReturn(...stubbings)
}
} |
Ok, thanks for consideration. I will probably do own helper as you suggested since it makes my code lot more readable. |
When I use one line to create new function stub and return some arguments, it gets messy really fast. So instead of writing
It would be possible to write something like this
The text was updated successfully, but these errors were encountered: