@charmander/test
Advanced tools
Comparing version 0.4.0-pre.1 to 0.4.0-pre.2
16
index.js
@@ -33,2 +33,8 @@ 'use strict'; | ||
const checkNested = testGroup => { | ||
if (testGroup._definingNested) { | ||
throw new Error('Can’t modify a test group while a test inside it is being defined (did you remember to include `test` in its parameter list?)'); | ||
} | ||
}; | ||
class TestGroup { | ||
@@ -41,5 +47,7 @@ constructor(path) { | ||
this.groups = []; | ||
this._definingNested = false; | ||
} | ||
addTest(name, run) { | ||
checkNested(this); | ||
checkPush(this.tests, new TestItem([...this.path, name], run)); | ||
@@ -49,2 +57,4 @@ } | ||
addSetup(name, run) { | ||
checkNested(this); | ||
if (run === undefined) { | ||
@@ -59,2 +69,4 @@ run = name; | ||
addTeardown(name, run) { | ||
checkNested(this); | ||
if (run === undefined) { | ||
@@ -77,5 +89,9 @@ run = name; | ||
checkNested(this); | ||
const group = new TestGroup([...this.path, name]); | ||
this.groups.push(group); | ||
this._definingNested = true; | ||
contents(group._boundAddTest()); | ||
this._definingNested = false; | ||
} | ||
@@ -82,0 +98,0 @@ |
@@ -79,6 +79,17 @@ 'use strict'; | ||
let {pass, total} = summary; | ||
forEach( | ||
group.groups, | ||
(group, callback) => { | ||
run(output, group, callback); | ||
run(output, group, (error, groupSummary) => { | ||
if (error) { | ||
callback(error); | ||
return; | ||
} | ||
pass += groupSummary.pass; | ||
total += groupSummary.total; | ||
callback(null); | ||
}); | ||
}, | ||
@@ -97,3 +108,3 @@ error => { | ||
callback(null, summary); | ||
callback(null, {pass, total}); | ||
}); | ||
@@ -100,0 +111,0 @@ } |
{ | ||
"name": "@charmander/test", | ||
"version": "0.4.0-pre.1", | ||
"version": "0.4.0-pre.2", | ||
"description": "Basic test organization", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
9303
302