/
ignore.spec.js
75 lines (69 loc) · 1.93 KB
/
ignore.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
'use strict';
var path = require('path').posix;
var helpers = require('../helpers');
var runMochaJSON = helpers.runMochaJSON;
var resolvePath = helpers.resolveFixturePath;
describe('--ignore', function() {
/*
* Runs mocha in {path} with the given args.
* Calls handleResult with the result.
*
* @param {string} fixture
* @param {string[]} args
* @param {function} handleResult
* @param {function} done
*/
function runMochaTest(fixture, args, handleResult, done) {
runMochaJSON(fixture, args, function(err, res) {
if (err) {
return done(err);
}
handleResult(res);
done();
});
}
it('should ignore specific files', function(done) {
var fixtures = path.join('options', 'ignore', '*');
runMochaTest(
fixtures,
['--ignore', resolvePath(path.join('options', 'ignore', 'fail'))],
function(res) {
expect(res, 'to have passed')
.and('to have run test', 'should find this test')
.and('not to have pending tests');
},
done
);
});
it('should ignore globbed files', function(done) {
var fixtures = path.join('options', 'ignore', '**', '*');
runMochaTest(
fixtures,
['--ignore', '**/fail.fixture.js'],
function(res) {
expect(res, 'to have passed')
.and('not to have pending tests')
.and('to have passed test count', 2);
},
done
);
});
it('should ignore multiple patterns', function(done) {
var fixtures = path.join('options', 'ignore', '**', '*');
runMochaTest(
fixtures,
[
'--ignore',
resolvePath(path.join('options', 'ignore', 'fail')),
'--ignore',
resolvePath(path.join('options', 'ignore', 'nested', 'fail'))
],
function(res) {
expect(res, 'to have passed')
.and('not to have pending tests')
.and('to have passed test count', 2);
},
done
);
});
});