Skip to content

Commit

Permalink
Merge pull request #19 from coursera/jw/failed-tests
Browse files Browse the repository at this point in the history
Removing test file overrides, specifying file names for failed hooks
  • Loading branch information
jnwng committed Feb 12, 2016
2 parents dcae3c8 + 9d25254 commit d15856c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 23 deletions.
28 changes: 6 additions & 22 deletions lib/mocha.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,6 @@ var files = require('./files');
var async = require('async');
var path = require('path');

/**
* Override some of bdd's post-require definitions in order to save file name in the test
* for xunit to output.
*/
var overrideBddIt = function(context, file, mocha) {
/**
* Describe a specification or test-case
* with the given `title` and callback `fn`
*/

var oldIt = context.it;
context.it = context.specify = function(title, fn){
var test = oldIt(title, fn);
test.file = file.replace(process.cwd(), '');
return test;
};
context.it.only = oldIt.only;
};

function setupMocha(mochaOptions, mochaExports) {
var mocha = new Mocha(mochaOptions);

Expand All @@ -31,8 +12,6 @@ function setupMocha(mochaOptions, mochaExports) {
_.each(_.isObject(mochaExports) ? mochaExports : {}, function(req, key) {
context[key] = req;
});

overrideBddIt(context, file, mocha);
});

return mocha;
Expand All @@ -54,7 +33,12 @@ function runMocha(mocha, testFile, done) {

runner.on('fail', function(test, err){
if (process && process.send) {
process.send({status:'fail', file:test.file, title:test.title, message:err.message});
process.send({
status: 'fail',
file: test.file || test.parent && test.parent.file,
title: test.title,
message: err.message
});
}
});

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "triple-latte",
"version": "0.3.0",
"version": "0.4.0",
"private": true,
"author": {
"name": "eleith",
Expand Down

0 comments on commit d15856c

Please sign in to comment.