Skip to content

testlab: expect(spy).to.be.called() #641

@bajtos

Description

@bajtos

Code to reproduce the problem:

const spy = sinon.spy(console, 'log');
console.log('hello');
expect(spy).to.be.called();

Error message:

TypeError: testlab_1.expect(...).to.be.called() is not a function

I did a quick search, we are using should/as-function for expect, which has different Assertion class/constructor than regular should. Now should-sinon modifies only the Assertion prototype from should, not from should/as-function, therefore it does not add sinon-related assertions to our `expect.

See https://github.com/shouldjs/sinon/blob/3d1841d244316a02671b54a33660127def0dd8b6/should-sinon.js#L5

Workaround:

sinon.assert.called(spy);

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions