Promise.resolve(aMockObject) return a Promise with pending status
See original GitHub issueI 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:
- Created 5 years ago
- Comments:11 (4 by maintainers)
Top 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 >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 FreeTop 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
Top GitHub Comments
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.
Thank you so much guys! Please spread the word.