@quarterto/stub-all

simplifies creating a lot of (sinon) stubs in your (mocha) tests

Usage no npm install needed!

<script type="module">
  import quartertoStubAll from 'https://cdn.skypack.dev/@quarterto/stub-all';
</script>

README

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, resets them all in beforeEach (making sure things like wasCalled are clean in each test, and restores them all in after.

licence

ISC