Skip to content

Latest commit

 

History

History
95 lines (72 loc) · 1.42 KB

README.md

File metadata and controls

95 lines (72 loc) · 1.42 KB

deptest

depject plugin for tests

Give tests from your depject modules.

Usage

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

API

Needs

exports.needs = nest({
  'tests': 'reduce'
})

Gives

exports.gives = nest({
  'test'
})

Giving tests functions

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) =>{}   
}

Install

With npm installed, run

$ npm install deptest

See Also

License

MIT