Good, so give information. This is what I would do. Suppose this is in your dev environment.
Using Mocha with Gulp to save a background thread.
So this is what you need to do.
Turn the mocha dependency into package.json
, test.js.
1. JS .
, , js db.
var assert = require('assert');
var connect = require('./connect');
var dbInterface = require('./interface');
describe('dbInterface', function() {
Gulp .
. gulp gulp-mocha .
gulpfile.js , , test.js interface.js i.e .
var gulp = require('gulp');
var mocha = require('gulp-mocha');
gulp.task('watch', function() {
gulp.watch(['./test.js', './interface.js'], ['test']);
});
. npm install
. npm run watch .
, . test.js. JS , .
: .
script , , script.js
exports.script = function(req,callback){
var spawn = require('child_process').spawn;
var child = spawn('node', ['GenerateBlob.js']);
child.stdout.on('data', function (data) {
var result = data.toString();
});
child.stderr.on('data', function (data) {
console.log('There was an error: ' + data);
});
});
, test.js
var assert = require('assert');
var childInterface= require('./script');
describe('testingscript', function() {
it('can run the script successfully', function(done) {
childInterface.script(null, function(error) {
assert.ifError(error);
console.log('wahtever message');
});
});
.
, ,
.\node_modules\.bin\mocha test.js
, node srcipt.js .
, . , .