UnitTestJS

From Yefu's notes
Jump to: navigation, search
"use strict" 
var chai = require('chai');
chai.should();

describe('Test1', function(){
    it('it1', function(done){
        let a = 1;
        a.should.equal(1);
        done();
    });
});

To drive it in gulp:

gulp.task('test', ['set-env'], () => {
    process.env.NODE_ENV='test';
    return gulp.src('test/test_*.js', {read: false})
    .pipe(mocha({"exit":true, "bail":true}))
    .once('error', () => {
        console.log('Exit by error');
        process.exit(1);
    })
    .once('end', () => {
        process.exit();
    });}
);