From 2c2ca73c223908877ed5362deff7f5fd50d2a41c Mon Sep 17 00:00:00 2001 From: Pierre-Yves Gerardy Date: Tue, 10 Jan 2017 21:29:34 +0100 Subject: [PATCH] [ospec] Add the possibility to name new test suites --- ospec/ospec.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ospec/ospec.js b/ospec/ospec.js index f153e841..36a8807f 100644 --- a/ospec/ospec.js +++ b/ospec/ospec.js @@ -1,8 +1,10 @@ "use strict" -module.exports = new function init() { +module.exports = new function init(name) { var spec = {}, subjects = [], results = [], only = null, ctx = spec, start, stack = 0, nextTickish, hasProcess = typeof process === "object", hasOwn = ({}).hasOwnProperty + if (name != null) spec[name] = ctx = {} + function o(subject, predicate) { if (predicate === undefined) return new Assert(subject) ctx[unique(subject)] = predicate @@ -210,6 +212,7 @@ module.exports = new function init() { } } console.log( + (name ? name + ": " : "") + results.length + " assertions completed in " + Math.round(new Date - start) + "ms, " + "of which " + results.filter(function(result){return result.error}).length + " failed" )