Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chai-spies broken in v5.1.0 #1610

Open
iampava opened this issue Mar 4, 2024 · 1 comment
Open

chai-spies broken in v5.1.0 #1610

iampava opened this issue Mar 4, 2024 · 1 comment

Comments

@iampava
Copy link

iampava commented Mar 4, 2024

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 iampava changed the title Upgrade to ES Modules have broken chai-spies Upgrade to ES Modules has broken chai-spies Mar 4, 2024
@iampava iampava changed the title Upgrade to ES Modules has broken chai-spies chai-spies broken in v5.1.0 Mar 4, 2024
@43081j
Copy link
Contributor

43081j commented Mar 4, 2024

this is most likely caused by #1569

you can do:

import * as chaiModule from 'chai';

const chai = chaiModule.use(chaiSpies);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants