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