Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
upgrade to [email protected]; closes #2859
- ensure we can run the test suite with `DEBUG=mocha*` by removing it
  when spawning `mocha`
- remove some cruft in the test helpers
  • Loading branch information
boneskull committed Jun 16, 2017
commit b37fb654ed88deed1c17656468aafbb49bc9f1d4
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@
"dependencies": {
"browser-stdout": "1.3.0",
"commander": "2.9.0",
"debug": "2.6.0",
"debug": "2.6.8",
"diff": "3.2.0",
"escape-string-regexp": "1.0.5",
"glob": "7.1.1",
Expand Down
46 changes: 2 additions & 44 deletions test/integration/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

var spawn = require('child_process').spawn;
var path = require('path');
var fs = require('fs');
var baseReporter = require('../../lib/reporters/base');

module.exports = {
Expand Down Expand Up @@ -41,47 +40,6 @@ module.exports = {
});
},

/**
* Invokes the mocha binary on the code of the body of the function.
* Accepts an array of additional command line args to pass. The callback is
* invoked with a summary of the run, in addition to its output. The summary
* includes the number of passing, pending, and failing tests, as well as the
* exit code. Useful for testing different reporters.
*
* Example response:
* {
* pending: 0,
* passing: 0,
* failing: 1,
* code: 1,
* output: '...'
* }
*
* @param {function} fixture
* @param {array} args
* @param {function} fn
*/
runMochaFunction: function (fixture, args, fn) {
var path = resolveFixturePath(fixture.name + '.js' || 'tempfile.js');
args = args || [];

var fixtureContent = 'var fn = ' + fixture.toString() + '; fn()';
fs.writeFileSync(path, fixtureContent, 'utf8');

function cleanup () {
fs.unlink(path);
fn.apply(this, arguments);
}

invokeMocha(args.concat(['-C', path]), function (err, res) {
if (err) {
return cleanup(err);
}

cleanup(null, getSummary(res));
});
},

/**
* Invokes the mocha binary for the given fixture using the JSON reporter,
* returning the parsed output, as well as exit code.
Expand Down Expand Up @@ -157,10 +115,10 @@ module.exports = {

function invokeMocha (args, fn) {
var output, mocha, listener;

// ensure DEBUG doesn't kill tests
output = '';
args = [path.join('bin', 'mocha')].concat(args);
mocha = spawn(process.execPath, args);
mocha = spawn(process.execPath, args, {env: {}});

listener = function (data) {
output += data;
Expand Down