I'm trying to test a function that calls the module cors
. I want to test that cors
would be called. For that, I'd have to stub/mock it.
Here is the function cors.js
const cors = require("cors");
const setCors = () => cors({origin: 'http//localhost:3000'});
module.exports = { setCors }
My idea of testing such function would be something like
cors.test.js
describe("setCors", () => {
it("should call cors", () => {
sinon.stub(cors)
setCors();
expect(cors).to.have.been.calledOnce;
});
});
Any idea how to stub npm module?