☕️ Classic, reliable, trusted test framework for Node.js and the browser
Changed: pass Test object to beforEach/afterEach
Tj Holowaychuk04cd1a566b6d
diff --git a/lib/runner.js b/lib/runner.jsindex 78e443b9..4cdc08aa 100644--- a/lib/runner.js+++ b/lib/runner.js@@ -64,7 +64,7 @@ Runner.prototype.runTests = function(suite, fn){self.emit('test', test);// run any befores firstsuite.setup.forEach(function(fn){- fn();+ fn(test);});// run the testtry {@@ -96,7 +96,7 @@ Runner.prototype.runTests = function(suite, fn){self.emit('test end', test);// teardown hooksuite.tearDown.forEach(function(fn){- fn();+ fn(test);});run(tests.shift());}diff --git a/test/unit/basic.js b/test/unit/basic.jsdeleted file mode 100644index f0eda8e0..00000000--- a/test/unit/basic.js+++ /dev/null@@ -1,15 +0,0 @@--describe('serial', function(){- describe('before', function(){- var calls = [];-- before(function(test){- calls.push(test.fullTitle());- });-- it('one', function(){- console.log(calls);- });-- });-});\ No newline at end of filediff --git a/test/unit/beforeEach.serial.js b/test/unit/beforeEach.serial.jsnew file mode 100644index 00000000..ffac3037--- /dev/null+++ b/test/unit/beforeEach.serial.js@@ -0,0 +1,27 @@++describe('serial', function(){+ describe('beforeEach()', function(){+ var calls = [];++ beforeEach(function(test){+ calls.push(test.fullTitle());+ });++ it('one', function(){+ calls.should.eql(['serial beforeEach() one']);+ });++ it('two', function(){+ calls.should.eql([+ 'serial beforeEach() one'+ , 'serial beforeEach() two']);+ });++ it('three', function(){+ calls.should.eql([+ 'serial beforeEach() one'+ , 'serial beforeEach() two'+ , 'serial beforeEach() three']);+ });+ });+});\ No newline at end of file