Skip to content

armgit / mocha

Public Imported from GitHub
0

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

serial suite execution

Tj Holowaychuk679936bce21e
diff --git a/Makefile b/Makefile
index e845671a..3c5267af 100644
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,5 @@
-TESTS = test/unit/hook.async.js
+TESTS = test/unit/*.js
REPORTER = list
test: test-unit
diff --git a/lib/runner.js b/lib/runner.js
index 5cb57b50..f0631878 100644
--- a/lib/runner.js
+++ b/lib/runner.js
@@ -165,22 +165,20 @@ Runner.prototype.runTests = function(suite, fn){
*/
Runner.prototype.runSuite = function(suite, fn){
- var self = this;
+ var self = this
+ , i = 0;
this.emit('suite', this.suite = suite);
- // pending tests
- var pending = suite.suites.length + 1;
-
- // run tests
- this.runTests(suite, function(){
- --pending || fn();
- });
+ function next(err) {
+ var curr = suite.suites[i++];
+ if (!curr) return fn();
+ self.runSuite(curr, next);
+ }
- // run sub-suites
- suite.suites.forEach(function(suite){
- self.runSuite(suite, function(){
- --pending || fn();
+ this.hook('beforeAll', function(err){
+ self.runTests(suite, function(err){
+ self.hook('afterAll', next);
});
});
};