Skip to content

armgit / mocha

Public Imported from GitHub
0

☕️ Classic, reliable, trusted test framework for Node.js and the browser

Issue 950 - Export file on Mocha.Test objects

Gareth Aye3dd1cdbb695f
diff --git a/lib/interfaces/bdd.js b/lib/interfaces/bdd.js
index e1581dab..cca6155b 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 6b229c0f..d933274f 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 a1150c36..0c02977a 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 f5b78e00..3df2508b 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;
};