stub-all
simplifies creating a lot of (sinon) stubs in your (mocha) tests
installation
npm install @quarterto/stub-all
usage
const stubAll = require('@quarterto/stub-all');
const sinon = require('sinon');
describe('foo', () => {
stubAll(() => [
sinon.stub(foo, 'bar'),
sinon.stub(foo, 'baz'),
sinon.stub(foo, 'quux'),
])
});
Pass a function returning an array of stubs to stubAll
. It calls the function in before
, creating your stubs, reset
s them all in beforeEach
(making sure things like wasCalled
are clean in each test, and restore
s them all in after
.
licence
ISC