Here's my npm script (defined in my package.json of course) that I'm running:
"scripts": {
"test": "gulp && mocha-casperjs test/features/specs/*-spec.js"
}
for some reason, all my gulp tasks run fine, but my mocha tests never run. So what I see when gulp is completely done is this:
$ npm test
> [email protected] test /Users/me/code/projects/we-do-tdd
> gulp && mocha-casperjs test/features/specs/*-spec.js
[17:34:50] Using gulpfile ~/code/projects/someApp/gulpfile.js
[17:34:50] Starting 'default'...
[17:34:50] Starting 'bundleApp'...
[17:34:50] Finished 'bundleApp' after 17 ms
[17:34:50] Starting 'watch'...
[17:34:50] Finished 'watch' after 7.33 ms
[17:34:50] Starting 'startApp'...
[17:34:50] Finished 'startApp' after 6.63 ms
[17:34:50] Finished 'default' after 34 ms
gulpfile
"use strict";
var app = require('./server'),
gulp = require('gulp'),
runSequence = require('run-sequence'),
browserify = require('browserify'),
source = require('vinyl-source-stream'),
gutil = require('gulp-util'),
babelify = require('babelify');
var scriptsCount = 0;
gulp.task('default', function (cb){
runSequence(['bundleApp','watch'], ['startApp'], cb)
});
gulp.task('watch', function () {
gulp.watch(['./src/*.js'], ['scripts']);
});
gulp.task('startApp', function (cb) {
app.listen(3000, cb).on('error', function(err) {
console.log(err);
});;
});
gulp.task('bundleApp', function () {
bundleApp(false);
});
function bundleApp() {
scriptsCount++;
var appBundler = browserify({
entries: './src/components/app.js',
debug: true
})
appBundler
.transform("babelify", {presets: ["es2015", "react"]})
.bundle()
.on('error', gutil.log)
.pipe(source('bundle.js'))
.pipe(gulp.dest('./build/app/js'));
}
The command after the && gets executed AFTER the first command has finsihed, because your default gulp task does not terminate, the second command never gets called.
Use:
"test": "gulp & mocha-casperjs test/features/specs/*-spec.js"
with one & to run the commands at the same time.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With