diff --git a/api.js b/api.js index 0101e9366..e398f91ef 100644 --- a/api.js +++ b/api.js @@ -195,7 +195,7 @@ function handlePaths(files) { files = [ 'test.js', 'test-*.js', - 'test/*.js' + 'test' ]; } @@ -209,7 +209,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; diff --git a/cli.js b/cli.js index 8c7adfc36..2301a04e6 100755 --- a/cli.js +++ b/cli.js @@ -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: [ '_', diff --git a/readme.md b/readme.md index bebfdb0ba..7a16c0489 100644 --- a/readme.md +++ b/readme.md @@ -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. diff --git a/test/api.js b/test/api.js index 53c3f7b94..700f67065 100644 --- a/test/api.js +++ b/test/api.js @@ -238,6 +238,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); diff --git a/test/fixture/subdir/failing-subdir.js b/test/fixture/subdir/failing-subdir.js new file mode 100644 index 000000000..351c571e7 --- /dev/null +++ b/test/fixture/subdir/failing-subdir.js @@ -0,0 +1,5 @@ +import test from '../../../'; + +test('subdir fail', t => { + t.fail(); +}); diff --git a/test/fixture/subdir/in-a-subdir.js b/test/fixture/subdir/in-a-subdir.js new file mode 100644 index 000000000..3022a6714 --- /dev/null +++ b/test/fixture/subdir/in-a-subdir.js @@ -0,0 +1,5 @@ +import test from '../../../'; + +test('subdir', t => { + t.pass(); +}); diff --git a/test/fixture/subdir/nested/nested.js b/test/fixture/subdir/nested/nested.js new file mode 100644 index 000000000..88e68ff6b --- /dev/null +++ b/test/fixture/subdir/nested/nested.js @@ -0,0 +1,5 @@ +import test from '../../../../'; + +test('subdir', t => { + t.pass(); +});