From 3dd1cdbb695f0489e03171c0874f4ccfb7347893 Mon Sep 17 00:00:00 2001 From: Gareth Aye Date: Thu, 27 Mar 2014 15:41:21 -0400 Subject: [PATCH] Issue 950 - Export file on Mocha.Test objects --- lib/interfaces/bdd.js | 1 + lib/interfaces/exports.js | 6 ++++-- lib/interfaces/qunit.js | 1 + lib/interfaces/tdd.js | 1 + 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/interfaces/bdd.js b/lib/interfaces/bdd.js index e1581dabe1..cca6155b07 100644 --- a/lib/interfaces/bdd.js +++ b/lib/interfaces/bdd.js @@ -109,6 +109,7 @@ module.exports = function(suite){ var suite = suites[0]; if (suite.pending) var fn = null; var test = new Test(title, fn); + test.file = file; suite.addTest(test); return test; }; diff --git a/lib/interfaces/exports.js b/lib/interfaces/exports.js index 6b229c0ff5..d933274fc7 100644 --- a/lib/interfaces/exports.js +++ b/lib/interfaces/exports.js @@ -28,7 +28,7 @@ module.exports = function(suite){ suite.on('require', visit); - function visit(obj) { + function visit(obj, file) { var suite; for (var key in obj) { if ('function' == typeof obj[key]) { @@ -47,7 +47,9 @@ module.exports = function(suite){ suites[0].afterEach(fn); break; default: - suites[0].addTest(new Test(key, fn)); + var test = new Test(key, fn); + test.file = file; + suites[0].addTest(test); } } else { var suite = Suite.create(suites[0], key); diff --git a/lib/interfaces/qunit.js b/lib/interfaces/qunit.js index a1150c362b..0c02977ac1 100644 --- a/lib/interfaces/qunit.js +++ b/lib/interfaces/qunit.js @@ -97,6 +97,7 @@ module.exports = function(suite){ context.test = function(title, fn){ var test = new Test(title, fn); + test.file = file; suites[0].addTest(test); return test; }; diff --git a/lib/interfaces/tdd.js b/lib/interfaces/tdd.js index f5b78e00b6..3df2508b6d 100644 --- a/lib/interfaces/tdd.js +++ b/lib/interfaces/tdd.js @@ -113,6 +113,7 @@ module.exports = function(suite){ var suite = suites[0]; if (suite.pending) var fn = null; var test = new Test(title, fn); + test.file = file; suite.addTest(test); return test; };