mercredi 17 février 2021

Proxyquire and Sinon to check if function is called

I'm trying to write a test within a file called fooTest that's trying to check if, in foo, when I call fooHandler, a function in bar is called.

Would I need to create a mock using Proxyquire? Here's what I have so far:

beforeEach {
    barMock = sinon.spy();
}
fooHandler = proxyQuire('path', {
    '../../path/to/bar': barMock
}

Not sure how I would check if bar's actually called. I want to check that bar is called once, but don't want to stub/change bar's behavior.

Aucun commentaire:

Enregistrer un commentaire