I have a spy that is used in multiple assertions across multiple tests in a suite.
How do I clear or reset the spy so that in each test the method that the spy intercepts is considered not to have been invoked?
For example, how to make the assertion in 'does not run method'
be true?
const methods = {
run: () => {}
}
const spy = jest.spyOn(methods, 'run')
describe('spy', () => {
it('runs method', () => {
methods.run()
expect(spy).toHaveBeenCalled() //=> true
})
it('does not run method', () => {
// how to make this true?
expect(spy).not.toHaveBeenCalled() //=> false
})
})