tape-pencil
v1.0.1
Published
A small helper for tape to inject dependencies into your tests
Downloads
3
Maintainers
Readme
Pencil for tape
A small helper to inject complex dependencies into your tape tests.
Install
yarn add --dev tape-pencil
API
testWithProvision(provider, [name], [opts], cb)
Create a new test with an optional name
string and optional opts
object.
cb(t, dep1, dep2, ..., depx)
is fired with the new test object along with the dependencies returned from calling the provider
function.
Example
import testWithProvision from 'tape-pencil';
function provideDependencies() {
return [{foo: 'bar'}, someDependency()];
}
testWithProvision(provideDependencies, 'Test this or that', (t, dependencyOne, dependencyTwo) => {
// dependencyOne: ({foo: 'bar'}) and dependencyTwo: (the return value of someDependency())
// are now available in your test
});