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);
The following code fails when using:
chai
: 5.1.0chai-spies
: 1.1.0The error is:
TypeError: chai.spy is not a function
However, if I downgrade to
v4.3.10
and use CJS with the following code:It works.