fix(vitest): accept awaited return type in vi.when().thenResolve - #11067
Open
ErfanBagheri404 wants to merge 1 commit into
Open
fix(vitest): accept awaited return type in vi.when().thenResolve#11067ErfanBagheri404 wants to merge 1 commit into
ErfanBagheri404 wants to merge 1 commit into
Conversation
|
Hello @ErfanBagheri404. Your PR has been labeled To keep your PR open, please follow these steps:
Please, do not generate or format the response with AI. If you do not speak English, reply in your native language or use translation software like Google Translate or Deepl. If the response is generated, the PR will be closed automatically. These measures help us reduce maintenance burden and keep the team's work efficient. See our AI contributions policy for more context. |
✅ Deploy Preview for vitest-dev ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
vi.when(spy).calledWith(...).thenResolve(value)currently requiresvalueto be the fullReturnType, forcing callers to writePromise.resolve('bar')for async mocks. This changesthenResolveandthenResolveOnceto acceptAwaited<ReturnType>, matching the existingmockResolvedValue/mockResolvedValueOncesignatures in@vitest/spy.The runtime path already wraps the value in
Promise.resolve(...)(when.tscase'resolve'), so this is purely a type-level fix — no behavior change.Before
After
Related
Closes #11017