co-test
v1.0.0
Published
An wapper that enables generators to be used in unit test, inspired by co
Downloads
3
Readme
co-test is a wapper that enables generators to be used in unit test, inspired by co.
Installation
$ npm install co-test
Usage
co-test lets you write your unit test by using generator functions. Like this:
/*
global describe it
*/
'use strict'
require('should')
var wrap = require('co-test');
describe('Test Module', function () {
it('Test Case', wrap(function * (done) {
let result = yield Promise.resolve(1)
result.should.be.equal(1)
done()
}))
})
When Error occur, co-test can catch it and show you
/*
global describe it
*/
'use strict'
require('should')
var wrap = require('co-test');
describe('Test Module', function () {
it('Test Case', wrap(function * (done) {
//Error Occur When you run this unit test
let result = yield Promise.reject(1)
result.should.be.equal(1)
done()
}))
})