Skip to content

Commit

Permalink
AVA now treats directories recursively
Browse files Browse the repository at this point in the history
Refs avajs#249.
  • Loading branch information
ariporad committed Dec 26, 2015
1 parent 945dbea commit 319e164
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
6 changes: 4 additions & 2 deletions api.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,10 @@ function handlePaths(files) {
if (files.length === 0) {
files = [
'test.js',
'**/test.js',
'test-*.js',
'test/*.js'
'**/test-*.js',
'test'
];
}

Expand All @@ -209,7 +211,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
11 changes: 11 additions & 0 deletions test/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,17 @@ test('absolute paths', function (t) {
});
});

test('recursive for directory', function (t) {
t.plan(1);

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

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

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

Expand Down
5 changes: 5 additions & 0 deletions test/fixture/subdir/in-a-subdir.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
var test = require('../../../');

test(function (t) {
t.pass();
});

0 comments on commit 319e164

Please sign in to comment.