forked from mochajs/mocha
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtimeout.spec.js
100 lines (83 loc) · 2.23 KB
/
timeout.spec.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
'use strict';
describe('timeouts', function () {
beforeEach(function (done) {
// uncomment
// setTimeout(done, 3000);
done();
});
it('should error on timeout', function (done) {
// uncomment
// setTimeout(done, 3000);
done();
});
it('should allow overriding per-test', function (done) {
this.timeout(1500);
setTimeout(function () {
done();
}, 50);
});
describe('disabling', function () {
it('should work with timeout(0)', function (done) {
this.timeout(0);
setTimeout(done, 1);
});
describe('using beforeEach', function () {
beforeEach(function () {
this.timeout(0);
});
it('should work with timeout(0)', function (done) {
setTimeout(done, 1);
});
});
describe('using before', function () {
before(function () {
this.timeout(0);
});
it('should work with timeout(0)', function (done) {
setTimeout(done, 1);
});
});
describe('using timeout(0)', function () {
this.timeout(4);
it('should suppress timeout(4)', function (done) {
this.slow(100);
// The test is in the before() call.
this.timeout(0);
setTimeout(done, 50);
});
});
describe('suite-level', function () {
this.timeout(0);
it('should work with timeout(0)', function (done) {
setTimeout(done, 1);
});
describe('nested suite', function () {
it('should work with timeout(0)', function (done) {
setTimeout(done, 1);
});
});
});
describe('chaining calls', function () {
before(function (done) {
setTimeout(function () {
done();
}, 50);
}).timeout(1500);
it('should allow overriding via chaining', function (done) {
setTimeout(function () {
done();
}, 50);
}).timeout(1500);
describe('suite-level', function () {
it('should work with timeout(0)', function (done) {
setTimeout(done, 1);
});
describe('nested suite', function () {
it('should work with timeout(0)', function (done) {
setTimeout(done, 1);
});
});
}).timeout(1000);
});
});
});