Describe the bug
If you call await expect(async () => { ... }).rejects.toThrow(), this will work as expected. However, change this to await expect(async () => { ... }).resolves.not.toThrow() and the test fails with the following error:
TypeError: You must provide a Promise to expect() when using .resolves, not 'function'.
This appears to just be an inconsistency between the two, based on the source code:


Seems like the Jest compatibility was not ported to .resolves but only to .rejects—looks like the bug is with that.
Reproduction
https://stackblitz.com/edit/vitest-dev-vitest-9omsvx?file=test%2Fbasic.test.ts
System Info
System:
OS: macOS 15.1
CPU: (10) arm64 Apple M2 Pro
Memory: 98.27 MB / 16.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 20.15.0 - ~/.nvm/versions/node/v20.15.0/bin/node
Yarn: 1.22.22 - /opt/homebrew/bin/yarn
npm: 10.7.0 - ~/.nvm/versions/node/v20.15.0/bin/npm
pnpm: 9.6.0 - /opt/homebrew/bin/pnpm
Browsers:
Safari: 18.1
npmPackages:
@vitest/coverage-v8: ^2.1.1 => 2.1.1
@vitest/ui: ^2.1.1 => 2.1.1
vitest: ^2.1.1 => 2.1.1
Used Package Manager
pnpm
Validations
Describe the bug
If you call
await expect(async () => { ... }).rejects.toThrow(), this will work as expected. However, change this toawait expect(async () => { ... }).resolves.not.toThrow()and the test fails with the following error:This appears to just be an inconsistency between the two, based on the source code:
Seems like the Jest compatibility was not ported to
.resolvesbut only to.rejects—looks like the bug is with that.Reproduction
https://stackblitz.com/edit/vitest-dev-vitest-9omsvx?file=test%2Fbasic.test.ts
System Info
System: OS: macOS 15.1 CPU: (10) arm64 Apple M2 Pro Memory: 98.27 MB / 16.00 GB Shell: 5.9 - /bin/zsh Binaries: Node: 20.15.0 - ~/.nvm/versions/node/v20.15.0/bin/node Yarn: 1.22.22 - /opt/homebrew/bin/yarn npm: 10.7.0 - ~/.nvm/versions/node/v20.15.0/bin/npm pnpm: 9.6.0 - /opt/homebrew/bin/pnpm Browsers: Safari: 18.1 npmPackages: @vitest/coverage-v8: ^2.1.1 => 2.1.1 @vitest/ui: ^2.1.1 => 2.1.1 vitest: ^2.1.1 => 2.1.1Used Package Manager
pnpm
Validations