Skip to content

4.1.0 upgrade breaking sinon-chai #9921

@jpzwarte

Description

@jpzwarte

Describe the bug

vitest.setup.ts:

import chaiDatetime from 'chai-datetime';
import chaiDom from 'chai-dom';
import sinonChai from 'sinon-chai';
import { chai } from 'vitest';
import { commands } from 'vitest/browser'

chai.use(chaiDatetime);
chai.use(chaiDom);
chai.use(sinonChai);

results in

Error: Failed to import test file /Users/jeroen.zwartepoorte/Projects/components/vitest.setup.ts
Caused by: TypeError: Cannot set property callCount of #<_Assertion> which has only a getter
 ❯ sinonPropertyAsBooleanMethod node_modules/sinon-chai/lib/sinon-chai.js:78:10
 ❯ sinon_chai_default node_modules/sinon-chai/lib/sinon-chai.js:146:2
 ❯ vitest.setup.ts:10:5

Uncommenting chai.use(sinonChai) will fix that, but now existing tests that use sinon break.

This worked fine with 4.0.17.

Reproduction

Don't have time atm to create a reproduction :/

System Info

System:
    OS: macOS 26.3.1
    CPU: (16) arm64 Apple M4 Max
    Memory: 2.62 GB / 64.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 24.13.0 - /opt/homebrew/bin/node
    Yarn: 4.13.0 - /opt/homebrew/bin/yarn
    npm: 11.6.2 - /opt/homebrew/bin/npm
  Browsers:
    Chrome: 146.0.7680.154
    Firefox: 148.0.2
    Firefox Developer Edition: 149.0
    Firefox Nightly: 142.0a1
    Safari: 26.3.1
    Safari Technology Preview: 26.0
  npmPackages:
    @vitest/browser-playwright: ^4.1.0 => 4.1.0 
    @vitest/coverage-v8: ^4.1.0 => 4.1.0 
    @vitest/ui: ^4.1.0 => 4.1.0 
    playwright: ^1.58.2 => 1.58.2 
    vite: ^8.0.1 => 8.0.1 
    vitest: ^4.1.0 => 4.1.0

Used Package Manager

npm

Validations

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions