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.

Promise.resolve(aMockObject) return a Promise with pending status

See original GitHub issue

I do something like this:

let mockFooA = Substitute.for<FooA>()
let mockFooB = Substitute.for<FooB>()
mockFooB.fooFunction().returns(Promise.resolve(mockFooA))

I found Promise.resolve(mockFooA) will return a Promise with “pending” status. Expected: “resolved”

when I use a Proxy instead of mockFooA like this:

Promise.resolve(new Proxy({}, handler))

it return a Promise with “resolved” status as expected

thx!

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:11 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
ffMathycommented, Sep 26, 2018

Ah fine report indeed!

It seems the proxy is forwarding the promise “then” method and makes the browser believe the substitute itself is a proxy.

Will find a workaround soon.

0reactions
ffMathycommented, Sep 29, 2018

Thank you so much guys! Please spread the word.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why is my asynchronous function returning Promise ...
The promise will always log pending as long as its results are not resolved yet. You must call .then on the promise to...
Read more >
Promise <pending> - Damaris Göbel
A promise represents a single asynchronous operation that hasn't been completed yet, but is expected in the future. The promise object ...
Read more >
JavaScript Promise Tutorial: Resolve, Reject, and Chaining ...
There are 3 states of the Promise object: Pending: Initial State, before the Promise succeeds or fails; Resolved: Completed Promise ...
Read more >
Async and Await in JavaScript, the extension to a promise.
That would look like writing return Promise.resolve('hello'). You can write an async function simply by placing the async keyword in front of the...
Read more >
Async / Await returning Promise <pending> instead of values
Hi, There seems to be an issue with Async/Await handling. Code below: async function getData() { console.log('logging'); const test = await ...
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