Skip to content

Commit

Permalink
Merge pull request #378 from ariporad/recursive
Browse files Browse the repository at this point in the history
Deeply recurse directories
  • Loading branch information
ariporad committed Dec 28, 2015
2 parents fc3b969 + 72e87d9 commit 96930e3
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 5 deletions.
4 changes: 2 additions & 2 deletions api.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ function handlePaths(files) {
files = [
'test.js',
'test-*.js',
'test/*.js'
'test'
];
}

Expand All @@ -207,7 +207,7 @@ function handlePaths(files) {
return files
.map(function (file) {
if (fs.statSync(file).isDirectory()) {
return handlePaths([path.join(file, '*.js')]);
return handlePaths([path.join(file, '**', '*.js')]);
}

return file;
Expand Down
3 changes: 2 additions & 1 deletion cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,12 @@ var cli = meow([
' ava',
' ava test.js test2.js',
' ava test-*.js',
' ava test',
' ava --init',
' ava --init foo.js',
'',
'Default patterns when no arguments:',
'test.js test-*.js test/*.js'
'test.js test-*.js test/**/*.js'
], {
string: [
'_',
Expand Down
5 changes: 3 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,15 @@ $ ava --help
ava
ava test.js test2.js
ava test-*.js
ava test
ava --init
ava --init foo.js
Default patterns when no arguments:
test.js test-*.js test/*.js
test.js test-*.js test/**/*.js
```

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.
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.

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

Expand Down
12 changes: 12 additions & 0 deletions test/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,18 @@ test('absolute paths', function (t) {
});
});

test('search directories recursivly for files', function (t) {
t.plan(1);

var api = new Api([path.join(__dirname, 'fixture/subdir')]);

api.run()
.then(function () {
t.is(api.passCount, 2);
t.is(api.failCount, 1);
});
});

test('titles of both passing and failing tests and AssertionErrors are returned', function (t) {
t.plan(3);

Expand Down

0 comments on commit 96930e3

Please sign in to comment.