chai icon indicating copy to clipboard operation
chai copied to clipboard

chai-spies broken in v5.1.0

Open iampava opened this issue 3 months ago • 1 comments

The following code fails when using:

  • chai: 5.1.0
  • chai-spies: 1.1.0
import * as chai from 'chai';
import chaiSpies from 'chai-spies';

chai.use(chaiSpies);
const expect = chai.expect;

function sum(a, b) {
    return a + b;
}

const spySum = chai.spy(sum);

expect(spySum).to.have.been.called.exactly(0);

The error is: TypeError: chai.spy is not a function


However, if I downgrade to v4.3.10 and use CJS with the following code:

const chai = require('chai');
const chaiSpies = require('chai-spies');

chai.use(chaiSpies);
const expect = chai.expect;

function sum(a, b) {
    return a + b;
}

const spySum = chai.spy(sum);

expect(spySum).to.have.been.called.exactly(0);

It works.

iampava avatar Mar 04 '24 10:03 iampava