-
-
Notifications
You must be signed in to change notification settings - Fork 771
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
Add documentation on how to test methods that return promises, linked… #2054
Conversation
Pull Request Test Coverage Report for Build 2918
💛 - Coveralls |
Coincidentally, I looked into all of these issues yesterday and actually followed up on this! Weird timing :) @orlangure already made a significant effort on this in #1931, which have unfortunately stalled for some time, but I think I'm merging this within a week. I'd rather have this build-upon that work, if that is fine with you? I'll ensure it doesn't drag on any longer than it needs to. Working beats perfect any day :) So, if you could just set this aside for a week, I'd just copy-paste the additions into the (soon to be) existing article. |
OK, #1931 has been merged. Could you see if you have stuff that is uncovered in https://github.com/sinonjs/sinon/blob/master/docs/_howto/lolex-async-promises.md and copy it in? |
@fatso83 my examples are realistic and show how to test simple async code with stubs and different arguments. Lolex is intended for more complex scenarios, f.x. setTimeout, setInterval... I think some developers might benefit in some opinionated and simple ways of testing async code. I am open to anything if we want to move it, change it or combine this with other documentation. What do you think? :D |
Right now, it's a demo of Mocha's API, along with some examples on doing async tests - which happen to use Promises. I think this is fine, but it's covering a bit of different ground than we were originally thinking of with #1898. I think your doc is basically the complement to your previous addition: https://github.com/sinonjs/sinon/blob/master/docs/_howto/stub-dependency.md. Maybe it would fit better there, as a section on how to stub out dependencies that are async? It could have your existing stuff, but possibly also an example on doing the same for classic callback passing async code. |
@fatso83 Good idea, I was thinking the same thing. I added them together and improved some texts. The thing that is now bothering me is that the examples: simple and asynchronous are not working on the same codebase(one is more real like...). Maybe it does not matter. What do you think, any feedback? |
I don't think the |
Issue #1898 is stale and talks about missing documentation for promises. Is this something we would like?
I can change the code to use dependency injection if we think more developers would use that. If we want that we need to decide constructor or property injection... :)
Purpose (TL;DR) - mandatory
How to verify - mandatory
npm install
Checklist for author
npm run lint
passes