| 1 | 'use strict'; |
| 2 | var assert = require('assert'); |
| 3 | |
| 4 | describe('skip in beforeEach', function() { |
| 5 | var runOrder = []; |
| 6 | beforeEach(function() { |
| 7 | runOrder.push('beforeEach'); |
| 8 | this.skip(); |
| 9 | }); |
| 10 | |
| 11 | it('should skip this test-1', function() { |
| 12 | throw new Error('never run this test'); |
| 13 | }); |
| 14 | |
| 15 | describe('inner', function() { |
| 16 | beforeEach(function() { |
| 17 | runOrder.push('should not run'); |
| 18 | }); |
| 19 | |
| 20 | it('should skip this test-2', function() { |
| 21 | throw new Error('never run this test'); |
| 22 | }); |
| 23 | it('should skip this test-3', function() { |
| 24 | throw new Error('never run this test'); |
| 25 | }); |
| 26 | |
| 27 | afterEach(function() { |
| 28 | runOrder.push('should not run'); |
| 29 | }); |
| 30 | }); |
| 31 | |
| 32 | afterEach(function() { |
| 33 | runOrder.push('afterEach'); |
| 34 | }); |
| 35 | after(function() { |
| 36 | runOrder.push('after'); |
| 37 | assert.deepStrictEqual(runOrder, [ |
| 38 | 'beforeEach', 'afterEach', |
| 39 | 'beforeEach', 'afterEach', |
| 40 | 'beforeEach', 'afterEach', |
| 41 | 'after' |
| 42 | ]); |
| 43 | throw new Error('should throw this error'); |
| 44 | }); |
| 45 | }); |