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