| 1 | 'use strict'; |
| 2 | var assert = require('assert'); |
| 3 | |
| 4 | describe('outer suite', function() { |
| 5 | var runOrder = []; |
| 6 | before(function() { |
| 7 | runOrder.push('outer before'); |
| 8 | }); |
| 9 | |
| 10 | it('should run test-1', function() { |
| 11 | runOrder.push('should run test-1'); |
| 12 | }); |
| 13 | |
| 14 | describe('inner suite', function() { |
| 15 | before(function() { |
| 16 | runOrder.push('inner before'); |
| 17 | this.skip(); |
| 18 | }); |
| 19 | |
| 20 | before(function() { |
| 21 | runOrder.push('inner before-2 should not run'); |
| 22 | }); |
| 23 | |
| 24 | beforeEach(function() { |
| 25 | runOrder.push('beforeEach should not run'); |
| 26 | }); |
| 27 | |
| 28 | afterEach(function() { |
| 29 | runOrder.push('afterEach should not run'); |
| 30 | }); |
| 31 | |
| 32 | after(function() { |
| 33 | runOrder.push('inner after'); |
| 34 | }); |
| 35 | |
| 36 | it('should never run this test', function() { |
| 37 | throw new Error('inner suite test should not run'); |
| 38 | }); |
| 39 | |
| 40 | describe('skipped suite', function() { |
| 41 | before(function() { |
| 42 | runOrder.push('skipped suite before should not run'); |
| 43 | }); |
| 44 | |
| 45 | it('should never run this test', function() { |
| 46 | throw new Error('skipped suite test should not run'); |
| 47 | }); |
| 48 | |
| 49 | after(function() { |
| 50 | runOrder.push('skipped suite after should not run'); |
| 51 | }); |
| 52 | }); |
| 53 | }); |
| 54 | |
| 55 | it('should run test-2', function() { |
| 56 | runOrder.push('should run test-2'); |
| 57 | }); |
| 58 | |
| 59 | after(function() { |
| 60 | runOrder.push('outer after'); |
| 61 | assert.deepStrictEqual(runOrder, [ |
| 62 | 'outer before', |
| 63 | 'should run test-1', 'should run test-2', |
| 64 | 'inner before', 'inner after', |
| 65 | 'outer after' |
| 66 | ]); |
| 67 | throw new Error('should throw this error'); |
| 68 | }); |
| 69 | }); |