vitest-dev / vitest-dev/vitest

Chai API is broken after `Promisify` (`resolves`/`rejects`)

Open
#7,513 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

p2-to-be-discussed pending triage
Dominant language
TypeScript
Stars
17.1k
Forks
2k
Avg merge
1d 21h
Merged PRs (30d)
92

Description

Describe the bug

Chai API that does not contain function (e.g., to.be.empty) is broken after Promisify (resolves/rejects) in runtime. Instead of successfully passing, it says:

Promise returned by `expect(actual).resolves.assert(expected)` was not awaited. Vitest currently auto-awaits hanging assertions at the end of the test, but this will cause the test to fail in Vitest 3. Please remember to await the assertion.
Reproduction

This is a small example of the issue.

System Info
System:
    OS: Linux 5.15 Ubuntu 22.04.5 LTS 22.04.5 LTS (Jammy Jellyfish)
    CPU: (12) x64 12th Gen Intel(R) Core(TM) i7-1255U
    Memory: 12.62 GB / 23.33 GB
    Container: Yes
    Shell: 5.1.16 - /bin/bash
  Binaries:
    Node: 22.14.0 - ~/.volta/tools/image/node/22.14.0/bin/node
    Yarn: 1.22.22 - ~/.volta/bin/yarn
    npm: 10.9.2 - ~/.volta/tools/image/node/22.14.0/bin/npm
    pnpm: 10.4.1 - ~/.volta/bin/pnpm
  Browsers:
    Chrome: 131.0.6778.85
  npmPackages:
    @vitejs/plugin-react: 4.3.4 => 4.3.4 
    @vitest/browser: 3.0.4 => 3.0.5 
    @vitest/coverage-v8: 3.0.4 => 3.0.5 
    @vitest/ui: 3.0.4 => 3.0.5 
    playwright: 1.50.0 => 1.50.1 
    vite: 6.0.11 => 6.1.0 
    vitest: 3.0.4 => 3.0.5
Used Package Manager

npm

Validations

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the reproduced test in test/basic.test.ts and trace the runtime handling of Chai assertions after resolves/rejects promisification. Reproduce the empty or other non-function assertion and verify that it passes without the unawaited-promise warning, while awaited assertions continue to behave correctly.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
testing-qa
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.