Skip to content

Commit 72e87d9

Browse files
committed
Deeply recurse directories.
Also, add tests and documentation. Fixes #249.
1 parent 8346d35 commit 72e87d9

File tree

7 files changed

+34
-5
lines changed

7 files changed

+34
-5
lines changed

api.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ function handlePaths(files) {
195195
files = [
196196
'test.js',
197197
'test-*.js',
198-
'test/*.js'
198+
'test'
199199
];
200200
}
201201

@@ -209,7 +209,7 @@ function handlePaths(files) {
209209
return files
210210
.map(function (file) {
211211
if (fs.statSync(file).isDirectory()) {
212-
return handlePaths([path.join(file, '*.js')]);
212+
return handlePaths([path.join(file, '**', '*.js')]);
213213
}
214214

215215
return file;

cli.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,12 @@ var cli = meow([
4848
' ava',
4949
' ava test.js test2.js',
5050
' ava test-*.js',
51+
' ava test',
5152
' ava --init',
5253
' ava --init foo.js',
5354
'',
5455
'Default patterns when no arguments:',
55-
'test.js test-*.js test/*.js'
56+
'test.js test-*.js test/**/*.js'
5657
], {
5758
string: [
5859
'_',

readme.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,14 +115,15 @@ $ ava --help
115115
ava
116116
ava test.js test2.js
117117
ava test-*.js
118+
ava test
118119
ava --init
119120
ava --init foo.js
120121
121122
Default patterns when no arguments:
122-
test.js test-*.js test/*.js
123+
test.js test-*.js test/**/*.js
123124
```
124125

125-
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.
126+
Directories are recursive by default. 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.
126127

127128
*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.
128129

test/api.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,18 @@ test('absolute paths', function (t) {
238238
});
239239
});
240240

241+
test('search directories recursivly for files', function (t) {
242+
t.plan(1);
243+
244+
var api = new Api([path.join(__dirname, 'fixture/subdir')]);
245+
246+
api.run()
247+
.then(function () {
248+
t.is(api.passCount, 2);
249+
t.is(api.failCount, 1);
250+
});
251+
});
252+
241253
test('titles of both passing and failing tests and AssertionErrors are returned', function (t) {
242254
t.plan(3);
243255

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

test/fixture/subdir/in-a-subdir.js

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

0 commit comments

Comments
 (0)