depject plugin for tests
Give tests from your depject modules.
const combine = require('depject')
const {first} = require('depject/apply')
const deptest = require('deptest')
const tests = {
gives: 'tests',
create: function (api) {
return function (tests) {
tests['addition'] = function (assert, cb) {
assert(1 + 1 === 2)
cb()
}
tests['async maths'] = function (assert, cb) {
setTimeout(() => {
assert(1 + 1 === 2)
cb()
}, 300)
}
return tests
}
}
}
//lines below would normally be in test.js or similar
//combine your tests with your other modules
const modules = combine([tests, deptest])
//Run the tests!
first(modules.test)()
outputs
✔ addition
✔ async maths
exports.needs = nest({
'tests': 'reduce'
})
exports.gives = nest({
'test'
})
You give tests
functions from your modules that have the shape:
(tests) => tests
Where tests is an object that has shape:
{
'my test name': (assert, cb) =>{}
}
With npm installed, run
$ npm install deptest
MIT