Closed dieterwalckiers closed 5 years ago
This package is designed to work with mocha
not jest
but as long as you are using sinon
and chai
it ought to work. But I have only ever tried it with mocha
. Chai/Sinon's syntax is different to Jest's. Try, at the top
const { expect } = require('chai')
and in your test
expect(OptionCategory.belongsTo).to.have.been.called
Ok, I got rid of jest completely in favor of mocha, it works now. I'm relatively new to testing frameworks, and the similar synaxt of jest and mocha made me confuse them with each other. Thanks a lot for your help!
Hello
I'm integrating sequelize-test-helpers in my unit tests, but I'm having some trouble testing the stubbed functions in the Models. When I run this test:
I get
Even though OptionCategory.belongsTo prints out as spy. I really don't understand why jest isn't taking it... This happens with all stubbed functions, by default or by me using sinon.
Here's a link to the test file in my (work in progress) repo, for context: https://bitbucket.org/dyte/authentic-catalog-api/src/master/tests/unit/models/optionCategory.ts
Thanks a lot for any hints! Dieter