Clean UT with gulpfile

From Yefu's notes
Jump to: navigation, search

gulpfile:

var gulp = require('gulp');
const mocha = require('gulp-mocha');

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

test file:

let chai = require('chai');
let should = chai.should();

describe('promiseChain', function(){
    it('first success', function(done){
        let value=2;
        value.should.equal(2);
        done();
    });
});

http test

"use strict" 

let chai = require('chai');
let chaiHttp = require('chai-http');
let server = require('../config/server');

chai.use(chaiHttp);
const request = chai.request(server);

describe('PUT /web/wallet', () =>{
    it('update wallet', function(done){
        request.put('/web/wallet')
            .send({"ETH":"abc123456","UMO":"cde45678"})
            .end((err, res) => {
                res.should.have.status(200);
                done();
            });
    });
});