| 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 | this.skip(); |
| 9 | }); |
| 10 | |
| 11 | it('should never run this outer test', function() { |
| 12 | throw new Error('outer suite test should not run'); |
| 13 | }); |
| 14 | |
| 15 | describe('inner suite', function() { |
| 16 | before(function() { runOrder.push('no inner before'); }); |
| 17 | before(function(done) { runOrder.push('no inner before'); done(); }); |
| 18 | before(async function() { runOrder.push('no inner before'); }); |
| 19 | before(function() { return Promise.resolve(runOrder.push('no inner before')) }); |
| 20 | |
| 21 | after(function() { runOrder.push('no inner after'); }); |
| 22 | after(function(done) { runOrder.push('no inner after'); done(); }); |
| 23 | after(async function() { runOrder.push('no inner after'); }); |
| 24 | after(function() { return Promise.resolve(runOrder.push('no inner after')) }); |
| 25 | |
| 26 | it('should never run this inner test', function() { |
| 27 | throw new Error('inner suite test should not run'); |
| 28 | }); |
| 29 | }); |
| 30 | |
| 31 | after(function() { |
| 32 | runOrder.push('outer after'); |
| 33 | assert.deepStrictEqual(runOrder, [ |
| 34 | 'outer before', 'outer after' |
| 35 | ]); |
| 36 | throw new Error('should throw this error'); |
| 37 | }); |
| 38 | }); |