I create gulp task for unit tests. I add nodemon for automatically run server then run test. But have error when run gulp task again. I have error that the port is already busy with another process.
I user this code:
var gulp = require('gulp'),
gulpUtil = require('gulp-util'),
gulpShell = require('gulp-shell'),
gulpEnv = require('gulp-env'),
gulpNodemon = require('gulp-nodemon'),
gulpMocha = require('gulp-mocha');
gulp.task('default', function () {
gulpUtil.log('unit - run unit tests');
});
gulp.task('server', function (callback) {
var started = false;
return gulpNodemon({
script: './build/app.js'
})
.on('start', function () {
if (!started) {
started = true;
return callback();
}
})
});
gulp.task('unit', ['server'], function () {
return gulp.src('./src/*.js')
.pipe(gulpMocha({reporter: 'spec'}))
.once('error', function () {
process.exit(1);
})
.once('end', function () {
process.exit();
})
});
How I can stop or kill server after unit tests?
via Metal Evolution Studio
No comments:
Post a Comment