Merge pull request #1529 from pygy/ospec-named-suites

[ospec] Add the possibility to name new test suites
This commit is contained in:
Pierre-Yves Gérardy 2017-07-06 22:15:45 +02:00 committed by GitHub
commit 34c3430420

View file

@ -1,9 +1,11 @@
/* eslint-disable no-bitwise, no-process-exit */
"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) {
if (results == null) throw new Error("Assertions should not occur outside test definitions")
@ -222,6 +224,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"
)