-
-
Notifications
You must be signed in to change notification settings - Fork 27
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
docs: add section about resolves
and removal of Promise unwrapping
#44
Conversation
size-limit report 📦
|
I had this option: https://github.com/tinylibs/tinyspy/compare/main...dubzzz:return-src-p?expand=1. |
@sheremet-va My option passes all the tests without any need to change them.
|
Vitest team decided to make that change at our last weekly, we are introducing Your option has hidden bugs because it introduced uncaught exceptions that are hard to catch, this is how it worked before actually |
Not really... The error is caught in my case. The |
The #14 is not the same: by throwing in the catch it causes an unhandled. In my case I never throw for the catch clause and thus there is no unhandled. |
I see. Still, it incorrectly stores the awaited result instead of the value that was actually returned by the function. I would expect a Promise to be in let promise
const mock = fn(() => {
promise = new Promise((resolve) => resolve(42))
return promise
})
mock.results[0] === promise
await mock
mock.results[0] === promise |
We can combine your solution with this though and introduce |
Do you mean something like: dubzzz@deeec2d? |
Yes |
Oh, no, sorry. I mean: result.then(
(r: any) => (state.resolves.push(r)),
(e: any) => (state.rejects.push(e))
) |
If we go for: result.then(
(r: any) => (state.resolves.push(r)),
(e: any) => (state.rejects.push(e))
) There is a question we must answer:
|
Yeah, I would expect it to be resolved in the order they are called. This is how |
Another name would be |
I have something like: dubzzz@00a1862 (drafty version) But I don't get why my |
I have a fully working version with tests at https://github.com/tinylibs/tinyspy/compare/main...dubzzz:return-src-p?expand=1. Let me know if relevant for a PR or not. |
PR welcome :) |
00b00ca
to
0f87f85
Compare
resolves
and removal of Promise unwrapping
No description provided.