☕️ Classic, reliable, trusted test framework for Node.js and the browser
Change tests to accomodate afterEach, fixes #797
Valentin Agachi7fae7fbb4568
diff --git a/test/hook.async.js b/test/hook.async.jsindex 1976f6fe..fd62932c 100644--- a/test/hook.async.js+++ b/test/hook.async.js@@ -16,18 +16,21 @@ describe('async', function(){, 'before test one', 'one', 'after'+ , 'after test one passed', 'parent after', 'parent before', 'before', 'before test two', 'two', 'after'+ , 'after test two passed', 'parent after', 'parent before', 'before', 'before test three', 'three', 'after'+ , 'after test three passed', 'parent after', 'after all', 'root after all']);@@ -81,6 +84,7 @@ describe('async', function(){, 'before test one', 'one', 'after'+ , 'after test one passed', 'parent after', 'parent before', 'before'@@ -97,12 +101,14 @@ describe('async', function(){, 'before test one', 'one', 'after'+ , 'after test one passed', 'parent after', 'parent before', 'before', 'before test two', 'two', 'after'+ , 'after test two passed', 'parent after', 'parent before', 'before'@@ -111,8 +117,12 @@ describe('async', function(){})afterEach(function(done){+ var ctx = this;process.nextTick(function(){calls.push('after');+ if (ctx.currentTest) {+ calls.push('after test ' + ctx.currentTest.title + ' ' + ctx.currentTest.state);+ }done();})})diff --git a/test/hook.sync.js b/test/hook.sync.jsindex eb20a209..c446c6aa 100644--- a/test/hook.sync.js+++ b/test/hook.sync.js@@ -33,6 +33,7 @@ describe('serial', function(){, 'before test one', 'one', 'after'+ , 'after test one passed', 'parent after', 'parent before', 'before'@@ -47,12 +48,14 @@ describe('serial', function(){, 'before test one', 'one', 'after'+ , 'after test one passed', 'parent after', 'parent before', 'before', 'before test two', 'two', 'after'+ , 'after test two passed', 'parent after', 'parent before', 'before'@@ -62,6 +65,9 @@ describe('serial', function(){afterEach(function(){calls.push('after');+ if (this.currentTest) {+ calls.push('after test ' + this.currentTest.title + ' ' + this.currentTest.state);+ }})after(function(){@@ -71,18 +77,21 @@ describe('serial', function(){, 'before test one', 'one', 'after'+ , 'after test one passed', 'parent after', 'parent before', 'before', 'before test two', 'two', 'after'+ , 'after test two passed', 'parent after', 'parent before', 'before', 'before test three', 'three', 'after'+ , 'after test three passed', 'parent after']);})})diff --git a/test/hook.sync.nested.js b/test/hook.sync.nested.jsindex 0a040b7b..94c00da5 100644--- a/test/hook.sync.nested.js+++ b/test/hook.sync.nested.js@@ -12,6 +12,9 @@ describe('serial', function(){afterEach(function(){calls.push('parent after');+ if (this.currentTest) {+ calls.push('parent after test ' + this.currentTest.title + ' ' + this.currentTest.state);+ }});it('foo', function(){@@ -27,6 +30,7 @@ describe('serial', function(){, 'parent before test foo', 'foo', 'parent after'+ , 'parent after test foo passed', 'parent before', 'parent before test bar']);})@@ -45,9 +49,11 @@ describe('serial', function(){, 'parent before test foo', 'foo', 'parent after'+ , 'parent after test foo passed', 'parent before', 'parent before test bar', 'parent after'+ , 'parent after test bar passed', 'parent before', 'parent before test one', 'before'@@ -61,16 +67,20 @@ describe('serial', function(){, 'parent before test foo', 'foo', 'parent after'+ , 'parent after test foo passed', 'parent before', 'parent before test bar', 'parent after'+ , 'parent after test bar passed', 'parent before', 'parent before test one', 'before', 'before test one', 'one', 'after'+ , 'after test one passed', 'parent after'+ , 'parent after test one passed', 'parent before', 'parent before test two', 'before'@@ -80,6 +90,9 @@ describe('serial', function(){afterEach(function(){calls.push('after');+ if (this.currentTest) {+ calls.push('after test ' + this.currentTest.title + ' ' + this.currentTest.state);+ }})})})