Skip to content

Commit b903fd1

Browse files
boneskulljuergba
authored andcommitted
rename "exclude" to "ignore" and create alias; closes #3871
1 parent 53f18a1 commit b903fd1

File tree

10 files changed

+36
-35
lines changed

10 files changed

+36
-35
lines changed

docs/index.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -817,7 +817,7 @@ Mocha supports the `err.expected` and `err.actual` properties of any thrown `Ass
817817

818818
<!-- AUTO-GENERATED-CONTENT:START (usage:executable=bin/mocha) -->
819819

820-
```plain
820+
```text
821821
822822
mocha [spec..]
823823
@@ -864,7 +864,7 @@ Configuration
864864
--package Path to package.json for config [string]
865865
866866
File Handling
867-
--exclude Ignore file(s) or glob pattern(s)
867+
--ignore, --exclude Ignore file(s) or glob pattern(s)
868868
[array] [default: (none)]
869869
--extension, --watch-extensions File extension(s) to load and/or watch
870870
[array] [default: js]
@@ -1075,9 +1075,9 @@ Specify an explicit path to a [`package.json` file](#configuring-mocha-nodejs) (
10751075

10761076
By default, Mocha looks for a `package.json` in the current working directory or nearest ancestor, and will use the first file found (regardless of whether it contains a `mocha` property); to suppress `package.json` lookup, use `--no-package`.
10771077

1078-
### `--exclude <file/directory/glob>`
1078+
### `--ignore <file|directory|glob>`
10791079

1080-
Explicitly exclude one or more files, directories or "globs" that would otherwise be loaded.
1080+
Explicitly ignore (exclude) one or more test files, directories or globs (e.g., `some/**/files*`) that would otherwise be loaded.
10811081

10821082
Files specified using `--file` _are not affected_ by this option.
10831083

@@ -1093,7 +1093,7 @@ Affects `--watch` behavior.
10931093

10941094
Specifying `--extension` will _remove_ `.js` as a test file extension; use `--extension js` to re-add it. For example, to load `.mjs` and `.js` test files, you must supply `--extension mjs --extension js`.
10951095

1096-
### `--file <file/directory/glob>`
1096+
### `--file <file|directory|glob>`
10971097

10981098
Explicitly _include_ a test file to be loaded before other test files files. Multiple uses of `--file` are allowed, and will be loaded in order given.
10991099

example/config/.mocharc.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ check-leaks: false
66
color: true
77
delay: false
88
diff: true
9-
exclude:
10-
- /path/to/some/excluded/file
119
exit: false # could be expressed as "no-exit: true"
1210
extension:
1311
- js
@@ -25,6 +23,8 @@ global:
2523
# fgrep and grep are mutually exclusive
2624
# grep: something
2725
growl: false
26+
ignore:
27+
- /path/to/some/ignored/file
2828
inline-diffs: false
2929
# needs to be used with grep or fgrep
3030
# invert: false
@@ -39,8 +39,8 @@ retries: 1
3939
slow: 75
4040
sort: false
4141
spec: test/**/*.spec.js # the positional arguments!
42-
v8-stack-trace-limit: 100 # V8 flags are prepended with "v8-"
4342
timeout: false # same as "no-timeout: true" or "timeout: 0"
4443
trace-warnings: true # node flags ok
4544
ui: bdd
45+
v8-stack-trace-limit: 100 # V8 flags are prepended with "v8-"
4646
watch: false

lib/cli/run-helpers.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,14 +123,14 @@ exports.handleRequires = (requires = []) => {
123123
* @param {Object} [opts] - Options
124124
* @param {string[]} [opts.extension] - File extensions to use
125125
* @param {string[]} [opts.spec] - Files, dirs, globs to run
126-
* @param {string[]} [opts.exclude] - Files, dirs, globs to exclude
126+
* @param {string[]} [opts.ignore] - Files, dirs, globs to ignore
127127
* @param {boolean} [opts.recursive=false] - Find files recursively
128128
* @param {boolean} [opts.sort=false] - Sort test files
129129
* @returns {string[]} List of files to test
130130
* @private
131131
*/
132132
exports.handleFiles = ({
133-
exclude = [],
133+
ignore = [],
134134
extension = [],
135135
file = [],
136136
recursive = false,
@@ -157,7 +157,7 @@ exports.handleFiles = ({
157157
newFiles = [newFiles];
158158
}
159159
newFiles = newFiles.filter(fileName =>
160-
exclude.every(pattern => !minimatch(fileName, pattern))
160+
ignore.every(pattern => !minimatch(fileName, pattern))
161161
);
162162
}
163163

lib/cli/run-option-metadata.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414
*/
1515
exports.types = {
1616
array: [
17-
'exclude',
1817
'extension',
1918
'file',
2019
'global',
20+
'ignore',
2121
'require',
2222
'reporter-option',
2323
'spec'
@@ -63,6 +63,7 @@ exports.aliases = {
6363
global: ['globals'],
6464
grep: ['g'],
6565
growl: ['G'],
66+
ignore: ['exclude'],
6667
invert: ['i'],
6768
'no-colors': ['C'],
6869
reporter: ['R'],

lib/cli/run.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,6 @@ exports.builder = yargs =>
8282
description: 'Show diff on failure',
8383
group: GROUPS.OUTPUT
8484
},
85-
exclude: {
86-
defaultDescription: '(none)',
87-
description: 'Ignore file(s) or glob pattern(s)',
88-
group: GROUPS.FILES,
89-
requiresArg: true
90-
},
9185
exit: {
9286
description: 'Force Mocha to quit after tests complete',
9387
group: GROUPS.RULES
@@ -143,6 +137,12 @@ exports.builder = yargs =>
143137
description: 'Enable Growl notifications',
144138
group: GROUPS.OUTPUT
145139
},
140+
ignore: {
141+
defaultDescription: '(none)',
142+
description: 'Ignore file(s) or glob pattern(s)',
143+
group: GROUPS.FILES,
144+
requiresArg: true
145+
},
146146
'inline-diffs': {
147147
description:
148148
'Display actual/expected differences inline within each string',

test/integration/fixtures/options/exclude/fail.fixture.js renamed to test/integration/fixtures/options/ignore/fail.fixture.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22

3-
describe('exclude test fail', function () {
3+
describe('ignore test fail', function () {
44
it('should not run this test', function () {
55
throw new Error('should not run');
66
});

test/integration/fixtures/options/exclude/nested/fail.fixture.js renamed to test/integration/fixtures/options/ignore/nested/fail.fixture.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22

3-
describe('exclude test nested fail', function () {
3+
describe('ignore test nested fail', function () {
44
it('should not run this test', function () {
55
throw new Error('should not run');
66
});
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
'use strict';
22

3-
describe('exclude test nested pass', function () {
3+
describe('ignore test nested pass', function () {
44
it('should find this test', function () {});
55
});
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
'use strict';
22

3-
describe('exclude test pass', function () {
3+
describe('ignore test pass', function () {
44
it('should find this test', function () {});
55
});

test/integration/options/exclude.spec.js renamed to test/integration/options/ignore.spec.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ var helpers = require('../helpers');
55
var runMochaJSON = helpers.runMochaJSON;
66
var resolvePath = helpers.resolveFixturePath;
77

8-
describe('--exclude', function() {
8+
describe('--ignore', function() {
99
/*
1010
* Runs mocha in {path} with the given args.
1111
* Calls handleResult with the result.
@@ -26,11 +26,11 @@ describe('--exclude', function() {
2626
});
2727
}
2828

29-
it('should exclude specific files', function(done) {
30-
var fixtures = path.join('options', 'exclude', '*');
29+
it('should ignore specific files', function(done) {
30+
var fixtures = path.join('options', 'ignore', '*');
3131
runMochaTest(
3232
fixtures,
33-
['--exclude', resolvePath(path.join('options', 'exclude', 'fail'))],
33+
['--ignore', resolvePath(path.join('options', 'ignore', 'fail'))],
3434
function(res) {
3535
expect(res, 'to have passed')
3636
.and('to have run test', 'should find this test')
@@ -40,11 +40,11 @@ describe('--exclude', function() {
4040
);
4141
});
4242

43-
it('should exclude globbed files', function(done) {
44-
var fixtures = path.join('options', 'exclude', '**', '*');
43+
it('should ignore globbed files', function(done) {
44+
var fixtures = path.join('options', 'ignore', '**', '*');
4545
runMochaTest(
4646
fixtures,
47-
['--exclude', '**/fail.fixture.js'],
47+
['--ignore', '**/fail.fixture.js'],
4848
function(res) {
4949
expect(res, 'to have passed')
5050
.and('not to have pending tests')
@@ -54,15 +54,15 @@ describe('--exclude', function() {
5454
);
5555
});
5656

57-
it('should exclude multiple patterns', function(done) {
58-
var fixtures = path.join('options', 'exclude', '**', '*');
57+
it('should ignore multiple patterns', function(done) {
58+
var fixtures = path.join('options', 'ignore', '**', '*');
5959
runMochaTest(
6060
fixtures,
6161
[
62-
'--exclude',
63-
resolvePath(path.join('options', 'exclude', 'fail')),
64-
'--exclude',
65-
resolvePath(path.join('options', 'exclude', 'nested', 'fail'))
62+
'--ignore',
63+
resolvePath(path.join('options', 'ignore', 'fail')),
64+
'--ignore',
65+
resolvePath(path.join('options', 'ignore', 'nested', 'fail'))
6666
],
6767
function(res) {
6868
expect(res, 'to have passed')

0 commit comments

Comments
 (0)