☕️ Classic, reliable, trusted test framework for Node.js and the browser
use invoker
Craig Taub41b29f1a4ebf
diff --git a/test/integration/helpers.js b/test/integration/helpers.jsindex cb633ac3..3b2e8263 100644--- a/test/integration/helpers.js+++ b/test/integration/helpers.js@@ -70,6 +70,21 @@ module.exports = {fn(null, result);});},+ runMochaJSONRaw: function(fixturePath, args, fn) {+ var path;++ path = resolveFixturePath(fixturePath);+ args = args || [];++ return invokeSubMocha(args.concat(['--reporter', 'json', path]), function(+ err,+ resRaw+ ) {+ if (err) return fn(err);++ fn(null, resRaw);+ });+ },/*** regular expression used for splitting lines based on new line / dot symbol.@@ -112,6 +127,12 @@ function invokeMocha(args, fn, cwd) {return _spawnMochaWithListeners(args, fn, cwd);}+function invokeSubMocha(args, fn, cwd) {+ args = [path.join(__dirname, '..', '..', 'bin', '_mocha')].concat(args);++ return _spawnMochaWithListeners(args, fn, cwd);+}+function invokeBlockingMocha(args, fn, cwd) {args = [path.join(diff --git a/test/integration/options.spec.js b/test/integration/options.spec.jsindex 375056cb..e7136228 100644--- a/test/integration/options.spec.js+++ b/test/integration/options.spec.js@@ -3,8 +3,9 @@var path = require('path');var helpers = require('./helpers');var run = helpers.runMochaJSON;+var runRaw = helpers.runMochaJSONRaw;var directInvoke = helpers.invokeMocha;-var directInvokeBlocking = helpers.invokeBlockingMocha;+// var directInvokeBlocking = helpers.invokeBlockingMocha;var resolvePath = helpers.resolveFixturePath;var args = [];@@ -505,7 +506,7 @@ describe('options', function() {});});- describe('--watch', function() {+ describe.only('--watch', function() {describe('with watch enabled', function() {it('should return correct output when watch process is terminated', function(done) {// After the process ends, this callback is ran@@ -513,7 +514,8 @@ describe('options', function() {this.timeout(0);this.slow(3000);// executes Mocha in a subprocess- var mocha = directInvokeBlocking(['--watch'], function(err, data) {+ // var mocha = directInvokeBlocking(['--watch'], function(err, data) {+ var mocha = runRaw('exit.fixture.js', ['--watch'], function(err, data) {clearTimeout(t);if (err) {done(err);@@ -521,14 +523,13 @@ describe('options', function() {}var expectedCloseCursor = '\u001b[?25h';- console.log('data', data);+ // console.log('data', data);expect(data.output, 'to contain', expectedCloseCursor);expect(data.code, 'to be', 130);done();});var t = setTimeout(function() {// kill the child process- console.log('TIMER SIGINT')mocha.kill('SIGINT');}, 500);});