/
timeout.spec.js
82 lines (76 loc) · 1.97 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
'use strict';
var helpers = require('../helpers');
var runMochaJSON = helpers.runMochaJSON;
describe('--timeout', function() {
it('should allow human-readable string value', function(done) {
runMochaJSON('options/slow-test', ['--timeout', '1s'], function(err, res) {
if (err) {
done(err);
return;
}
expect(res, 'to have failed')
.and('to have passed test count', 1)
.and('to have failed test count', 1);
done();
});
});
it('should allow numeric value', function(done) {
runMochaJSON('options/slow-test', ['--timeout', '1000'], function(
err,
res
) {
if (err) {
done(err);
return;
}
expect(res, 'to have failed')
.and('to have passed test count', 1)
.and('to have failed test count', 1);
done();
});
});
it('should allow multiple values', function(done) {
var fixture = 'options/slow-test';
runMochaJSON(fixture, ['--timeout', '2s', '--timeout', '1000'], function(
err,
res
) {
if (err) {
done(err);
return;
}
expect(res, 'to have failed')
.and('to have passed test count', 1)
.and('to have failed test count', 1);
done();
});
});
it('should disable timeout with "--inspect"', function(done) {
var fixture = 'options/slow-test';
runMochaJSON(fixture, ['--inspect', '--timeout', '200'], function(
err,
res
) {
if (err) {
done(err);
return;
}
expect(res, 'to have passed').and('to have passed test count', 2);
done();
});
});
it('should disable timeout with "-n inspect"', function(done) {
var fixture = 'options/slow-test';
runMochaJSON(fixture, ['-n', 'inspect', '--timeout', '200'], function(
err,
res
) {
if (err) {
done(err);
return;
}
expect(res, 'to have passed').and('to have passed test count', 2);
done();
});
});
});