From 714e0bf2855c82cdd6fcc88869b2d4e45724792d Mon Sep 17 00:00:00 2001 From: Ari Porad Date: Fri, 25 Dec 2015 20:13:46 -0800 Subject: [PATCH] AVA now treats directories recursivley --- api.js | 6 ++++-- test/api.js | 11 +++++++++++ test/fixture/subdir/in-a-subdir.js | 5 +++++ 3 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 test/fixture/subdir/in-a-subdir.js diff --git a/api.js b/api.js index 24c1be1f1..0c9983576 100644 --- a/api.js +++ b/api.js @@ -188,8 +188,10 @@ function handlePaths(files) { if (files.length === 0) { files = [ 'test.js', + '**/test.js', 'test-*.js', - 'test/*.js' + '**/test-*.js', + 'test' ]; } @@ -203,7 +205,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/test/api.js b/test/api.js index 53c3f7b94..0ff06f3a5 100644 --- a/test/api.js +++ b/test/api.js @@ -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); diff --git a/test/fixture/subdir/in-a-subdir.js b/test/fixture/subdir/in-a-subdir.js new file mode 100644 index 000000000..bb27c0b9a --- /dev/null +++ b/test/fixture/subdir/in-a-subdir.js @@ -0,0 +1,5 @@ +var test = require('../../../'); + +test(function (t) { + t.pass(); +});