Skip to content

Commit ab08598

Browse files
committed
Merge pull request #357 from sotojuan/ignore-fixture-helpers
Ignore files in fixtures and helpers directories
2 parents 94fbb1a + f6cef7f commit ab08598

File tree

5 files changed

+35
-3
lines changed

5 files changed

+35
-3
lines changed

api.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,8 @@ function handlePaths(files) {
195195
}
196196

197197
files.push('!**/node_modules/**');
198+
files.push('!**/fixtures/**');
199+
files.push('!**/helpers/**');
198200

199201
// convert pinkie-promise to Bluebird promise
200202
files = Promise.resolve(globby(files));

readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ $ ava --help
119119
test.js test-*.js test/*.js
120120
```
121121

122-
Files starting with `_` are ignored. This can be useful for having helpers in the same directory as your test files.
122+
Files in directories named `fixtures` and `helpers` are ignored, as well as files starting with `_`. This can be useful for having helpers in the same directory as your test files.
123123

124124
*WARNING: NON-STANDARD BEHAVIOR:* The AVA CLI will always try to find and use your projects local install of AVA. This is true even when you run the global `ava` command. This non-standard behavior solves an important [issue](https://github.com/sindresorhus/ava/issues/157), and should have no impact on everyday use.
125125

test/api.js

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,31 @@ test('testing nonexistent files rejects', function (t) {
302302
test('test file in node_modules is ignored', function (t) {
303303
t.plan(2);
304304

305-
var api = new Api([path.join(__dirname, 'fixture/node_modules/test.js')]);
305+
var api = new Api([path.join(__dirname, 'fixture/ignored-dirs/node_modules/test.js')]);
306+
307+
api.run()
308+
.catch(function (err) {
309+
t.ok(err);
310+
t.match(err.message, /Couldn't find any files to test/);
311+
});
312+
});
313+
314+
test('test file in fixtures is ignored', function (t) {
315+
t.plan(2);
316+
317+
var api = new Api([path.join(__dirname, 'fixture/ignored-dirs/fixtures/test.js')]);
318+
319+
api.run()
320+
.catch(function (err) {
321+
t.ok(err);
322+
t.match(err.message, /Couldn't find any files to test/);
323+
});
324+
});
325+
326+
test('test file in helpers is ignored', function (t) {
327+
t.plan(2);
328+
329+
var api = new Api([path.join(__dirname, 'fixture/ignored-dirs/helpers/test.js')]);
306330

307331
api.run()
308332
.catch(function (err) {

test/fixture/node_modules/test.js renamed to test/fixture/ignored-dirs/fixtures/test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import test from '../../';
1+
import test from '../../../../';
22

33
test(t => {
44
t.pass();
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import test from '../../../../';
2+
3+
test(t => {
4+
t.pass();
5+
t.end();
6+
});

0 commit comments

Comments
 (0)