Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,13 +165,6 @@ api.on('test-run', function (runStatus) {
});

var files = cli.input.length ? cli.input : arrify(conf.files);
if (files.length === 0) {
files = [
'test.js',
'test-*.js',
'test'
];
}

if (cli.flags.watch) {
try {
Expand Down
26 changes: 26 additions & 0 deletions test/ava-files.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,29 @@ test('findFiles - does not return duplicates of the same file', function (t) {
t.end();
});
});

test('findFiles - finds the correct files by default', function (t) {
var avaFiles = new AvaFiles(['**/ava-files/default-patterns/**']);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Argh. I'm realizing this is actually kinda hard to test.

This will actually find every file in the default-patterns folder.

Instead of this argument, can you just process.chdir() to the default-patterns folder, and drop the constructor argument?

You are technically overriding the default here.

#863 introduce cwd and resolveTestsFrom options, that would make this doable without changing the directory.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, you should sprinkle in a few files that should NOT be found (and ensure they are not).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can do that. Unfortunately I've run out of time. Someone can feel free to branch off of my branch and make the improvements in another PR if it needs to be fixed sooner than I can get to it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry Kent,
I see why you did it this way - It's exactly like the test I told you to copy. I'm updating your PR now. Expect a new PR and release soon.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. It's family time for me now. Sorry I didn't quite get to it.

var filesToFind = [
'sub/directory/__tests__/foo.js',
'sub/directory/bar.test.js',
'test-foo.js',
'test.js',
'test/baz.js'
];

avaFiles.findTestFiles().then(function (files) {
var allFilesFound = filesToFind.every(function (fileToFind) {
return files.some(function (file) {
return endsWith(file, fileToFind);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use slash to convert the results from \ results, to / results (I think).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

});
});
t.true(allFilesFound);
t.is(files.length, 5);
t.end();
});
});

function endsWith(str, suffix) {
return str.indexOf(suffix, str.length - suffix.length) !== -1;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// empty
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// empty
1 change: 1 addition & 0 deletions test/fixture/ava-files/default-patterns/test-foo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// empty
1 change: 1 addition & 0 deletions test/fixture/ava-files/default-patterns/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// empty
1 change: 1 addition & 0 deletions test/fixture/ava-files/default-patterns/test/baz.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// empty