support promises resolve/reject
See original GitHub issueI got an email asking for promise support. I didn’t think hard about it because I don’t have an immediate need.
What if we had this API?
td.config(promiseProvider: someFuncThatCreatesPromises)
td.when(...).thenResolve(someValue)
td.when(...).thenReject(someOtherValue)
And then maybe on the verification side?
td.verify.resolved(value)
td.verify.rejected(someOtherValue)
I don’t use promises much and I generally don’t TDD with them in mind (since I try to keep async stuff to the periphery of my app where I’m integrating with stuff). Any thoughts on how to go about this or what an example test would look like?
Paging @jasonkarns as he’s my promise whisperer
Issue Analytics
- State:
- Created 8 years ago
- Reactions:4
- Comments:7 (6 by maintainers)
Top Results From Across the Web
Promise - JavaScript - MDN Web Docs
Returns a new Promise object that is rejected with the given reason. Returns a new Promise object that is resolved with the given...
Read more >JavaScript Promise Tutorial: Resolve, Reject, and Chaining in ...
Firstly, we use a constructor to create a Promise object: const myPromise = new Promise();. It takes two ...
Read more >Promise - The Modern JavaScript Tutorial
A promise that is either resolved or rejected is called “settled”, as opposed to an initially “pending” promise. There can be only a...
Read more >Master JavaScript Promise: Resolve, Reject and Chaining
If, based on the condition, the promise gets rejected, the .catch method gets called and it logs the error. ... The .finally is...
Read more >JavaScript promise resolve() Method - GeeksforGeeks
The main advantage of using a Promise in JavaScript is that a user can assign callback functions to the promises in case of...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

I’ve started working on this issue. See the progress in my fork. Currently, only native
Promiseis supported.Thanks @mgryszko – I don’t think I can merge unless we make the
Promiseconstructor configurable. Sadly we live in the era of transpilers & polyfills and I don’t know anyone in practice who uses the native Promise object in production