| 1 | 'use strict'; |
| 2 | |
| 3 | describe('skip conditionally in beforeEach', function() { |
| 4 | var n = 1; |
| 5 | beforeEach(function() { |
| 6 | if (n !== 2) { |
| 7 | this.skip(); |
| 8 | } |
| 9 | }); |
| 10 | |
| 11 | it('should skip this test-1', function() { |
| 12 | throw new Error('never run this test'); |
| 13 | }); |
| 14 | it('should run this test-2', function() {}); |
| 15 | |
| 16 | describe('inner suite', function() { |
| 17 | it('should skip this test-3', function() { |
| 18 | throw new Error('never run this test'); |
| 19 | }); |
| 20 | }); |
| 21 | |
| 22 | afterEach(function() { n++; }); |
| 23 | after(function() { |
| 24 | if (n === 4) { |
| 25 | throw new Error('should throw this error'); |
| 26 | } |
| 27 | }); |
| 28 | }); |