|
|
@@ -12,7 +12,7 @@ var path = require("path"),
|
|
|
* if {Array}, should be list of tests
|
|
|
*/
|
|
|
module.exports = function runner(tests) { //jshint maxcomplexity:19
|
|
|
- var ctx = this && this !== global && this !== require("./") ? this : {};
|
|
|
+ var ctx = this && this.constructor === Object ? this : {};
|
|
|
if (!ctx.reporter) ctx.reporter = reporter;
|
|
|
if (typeof tests === "string") tests = require(ctx.file = path.resolve(tests));
|
|
|
if (Array.isArray(tests) && !ctx.parent) return tests.forEach(runner.bind(ctx));
|
|
|
@@ -27,7 +27,7 @@ module.exports = function runner(tests) { //jshint maxcomplexity:19
|
|
|
for (var key in ctx) {
|
|
|
if (ctx.hasOwnProperty(key) && !bench.hasOwnProperty(key)) bench[key] = ctx[key];
|
|
|
}
|
|
|
- reporter.call(ctx, bench);
|
|
|
+ ctx.reporter.call(ctx, bench);
|
|
|
try {
|
|
|
if (tests.beforeEach instanceof Function) tests.beforeEach.call(bench);
|
|
|
test.call(bench); // run once outside of bench for better error handling
|