Spy and mock methods in tests with great TypeScript support
npm install nanospyA tiny Node.js library to spy and mock methods in tests
with great TypeScript support.
It will take only 6 KB
in your node_modules and have 0 dependencies.
``js
import { spyOn, restoreAll } from 'nanospy'
test.after.each(() => {
restoreAll()
})
test('calls increase', () => {
const spy = spyOn(counter, 'increase')
counter.increase(5)
assert.equal(spy.callCount, 1)
assert.equal(spy.calls, [[5]])
})
``
alt="Sponsored by Evil Martians" width="236" height="54">