-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Add chainable .always
method
#474
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
Comments
Yep. That is the currently defined behavior. Your use case makes sense, so maybe we should change it. The current behavior is useful in other situations though (if Perhaps a |
Yeah, a So I would assume that the appropriate way to handle it would be to make |
Either that or just change |
I think it's definitely a valid request and has its right to be in the core. And |
What if we make this a default behavior? |
What if it's
Not sure the first one makes sense. |
I like this idea too.
Nope, it does not :) |
Seconded @vdemedes's last comment |
@sindresorhus can we get some |
👍 @therealklanni Done. Sorry about the delay. I've been traveling. |
No worries, thank you |
.always
method
@sindresorhus I started working on this a few weeks ago. Keep meaning to get back around to it, but I'm just swamped lately. Rather than leaving it stagnant any longer I wanted to let you know that I probably won't have time to work on it (certainly not any time soon). I just have too much going on right now, sorry. |
No worries @therealklanni! |
seems that class Sequence must be modified for this feature, I'll try to work on this issue, any advices? |
I'm not sure Sequence will need to be modified. Sequence takes a list of tasks and a boolean We currently build a list like this:
I think you could just wrap that in an non-bailing sequence:
|
This sequence building takes place in Chainable methods are defined here. |
Thanks for your advice! I'll try to wrap them as follows:
As for the chain modification, I'll add a new item |
I think you are on the right track. |
Hi @jamestalmage , I've opened a pull request #806, however it leads to some failure in other tests, could you have a look and give some advices? Thank you! |
@jamestalmage I've fixed the mistake, now it should work as desired |
Should an |
It should probably execute even if a |
Sorry to bring this up again, but should |
There are plenty of scenarios where you wouldn't want
I am not sure. That certainly makes sense in a serial test runner, where it is very likely you are using |
@jamestalmage in your example, do you mean verifying mocks in your I'm struggling with what to name the "only if there were no failures" after hook. |
Some mock libraries allow you to set up expectations, run your test, and then verify all expectations were actually called. Think of the verification step as the mocking equivalent of
Yeah, that's a potential problem, but I'm not sure how to avoid it.
|
Yea I think I prefer Given that these run after the normal after hooks, maybe |
I think finally helps communicate it comes last, don't know that it helps communicate the I think some users might be confused if they specified |
Implement chainable
always
method.From @jamestalmage's comment below:
Original message
Near as I can figure, the
.after()
hook is only being ran if the tests have passed. I have a test file something like this (simplified/pseudo for clarity)The text was updated successfully, but these errors were encountered: