-
-
Notifications
You must be signed in to change notification settings - Fork 3k
/
opts.spec.js
64 lines (56 loc) · 1.59 KB
/
opts.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
'use strict';
var path = require('path').posix;
var helpers = require('../helpers');
var runMochaJSON = helpers.runMochaJSON;
var invokeMocha = helpers.invokeMocha;
var resolvePath = helpers.resolveFixturePath;
describe('--opts', function() {
var args = [];
var fixture = path.join('options', 'opts');
it('should print a deprecation warning', function(done) {
var mochaOpts = path.join('test', 'opts', 'mocha.opts');
args = [resolvePath(fixture), '--opts', mochaOpts];
invokeMocha(
args,
function(err, res) {
if (err) {
return done(err);
}
expect(res, 'to have passed');
expect(res.output, 'to contain', 'mocha.opts is DEPRECATED');
done();
},
'pipe'
);
});
it('should work despite nonexistent default options file', function(done) {
args = [];
runMochaJSON(fixture, args, function(err, res) {
if (err) {
return done(err);
}
expect(res, 'to have passed').and('to have passed test count', 1);
done();
});
});
it('should throw an error due to nonexistent options file', function(done) {
var spawnOpts = {stdio: 'pipe'};
var nonexistentFile = 'nosuchoptionsfile';
args = ['--opts', nonexistentFile, resolvePath(fixture)];
invokeMocha(
args,
function(err, res) {
if (err) {
return done(err);
}
var pattern = 'unable to read ' + nonexistentFile;
expect(res, 'to satisfy', {
code: 1,
output: new RegExp(pattern, 'i')
});
done();
},
spawnOpts
);
});
});