Skip to content

fix(vitest): accept awaited return type in vi.when().thenResolve - #11067

Open
ErfanBagheri404 wants to merge 1 commit into
vitest-dev:mainfrom
ErfanBagheri404:fix/11017-thenResolve-awaited
Open

fix(vitest): accept awaited return type in vi.when().thenResolve#11067
ErfanBagheri404 wants to merge 1 commit into
vitest-dev:mainfrom
ErfanBagheri404:fix/11017-thenResolve-awaited

Conversation

@ErfanBagheri404

Copy link
Copy Markdown

Description

vi.when(spy).calledWith(...).thenResolve(value) currently requires value to be the full ReturnType, forcing callers to write Promise.resolve('bar') for async mocks. This changes thenResolve and thenResolveOnce to accept Awaited<ReturnType>, matching the existing mockResolvedValue / mockResolvedValueOnce signatures in @vitest/spy.

The runtime path already wraps the value in Promise.resolve(...) (when.ts case 'resolve'), so this is purely a type-level fix — no behavior change.

Before

vi.when(spy).calledWith('easter-egg').thenResolve(Promise.resolve('bar')) // required

After

vi.when(spy).calledWith('easter-egg').thenResolve('bar') // works

Related

Closes #11017

@github-actions github-actions Bot added the maybe automated User is likely an AI agent, or the content was generated by an AI assistant without user control label Aug 26, 2026
@github-actions

Copy link
Copy Markdown

Hello @ErfanBagheri404. Your PR has been labeled maybe automated because it appears to have been fully generated by AI with no human involvement.

To keep your PR open, please follow these steps:

  • Confirm that you are a real human. If you are an automated agent, disclose that
  • Make sure you've read, reviewed and stand behind its content
  • Make sure you've read the full issue along with all of its comments, as well as any linked issues and their comments
  • Make sure it follows our contribution guidelines and uses the correct GitHub template
  • Disclose any AI tools you used (e.g. Claude, Copilot, Codex)

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.

@netlify

netlify Bot commented Aug 26, 2026

Copy link
Copy Markdown

Deploy Preview for vitest-dev ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 02aa9c4
🔍 Latest deploy log https://app.netlify.com/projects/vitest-dev/deploys/6a8ea83d87b9c800086e500c
😎 Deploy Preview https://deploy-preview-11067--vitest-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maybe automated User is likely an AI agent, or the content was generated by an AI assistant without user control

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Still required to Promise.resolve in vi.when().thenResolve

1 participant