thunk-mocha

Enable support for generators in Mocha with backward compatibility.

MIT 11 个版本
安装
npm install thunk-mocha
yarn add thunk-mocha
pnpm add thunk-mocha
bun add thunk-mocha
README

thunk-mocha

Enable support for generators in Mocha with backward compatibility.

NPM version Build Status Downloads

It is similar to Co Mocha, but it is a different implementation and more powerful. It is a perfect patch for mocha!

Installation

npm install thunk-mocha

Usage

Call by mocha in CLI:

mocha -r thunk-mocha

Call in js file:

// make sure that `mocha` have loaded
require('thunk-mocha')()
// or: require('thunk-mocha')(require('mocha'))

Example

After patched, mocha support:

it('support sync test', function () {
  // do some test
})

it('support thunk style async test', function (done) {
  // do some test
  done()
})

it('support promise style async test', function () {
  // do some test
  return promiseLikeObject
})

it('support generator style async test', function * () {
  // do some test
  yield promise
  // yield thunk
  // yield generator
  // ...
})

it('support async/await style async test', async function () {
  // do some test
  await promise
})

it('support Rx.Observable style async test', function () {
  // do some test
  return Rx.Observable.bindNodeCallback(fs.stat)('package.json')
})
版本列表
1.0.8 2016-10-10
1.0.7 2016-10-07
1.0.6 2016-09-08
1.0.5 2016-08-29
1.0.4 2016-07-30
1.0.3 2016-02-07
1.0.2 2016-01-24
1.0.1 2015-11-29
1.0.0 2015-10-09
0.1.1 2015-09-26
0.1.0 2015-09-25