question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

support promises resolve/reject

See original GitHub issue

I 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:closed
  • Created 8 years ago
  • Reactions:4
  • Comments:7 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
mgryszkocommented, Jun 24, 2016

I’ve started working on this issue. See the progress in my fork. Currently, only native Promise is supported.

0reactions
searlscommented, Jun 24, 2016

Thanks @mgryszko – I don’t think I can merge unless we make the Promise constructor 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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found