Skip to content

Commit ce6a22d

Browse files
author
Kent C. Dodds
committed
fix(cli): Remove default files from CLI
The default files should be in one place (`ava-files.js`). Right now the defaults provided in `ava-files.js` aren't being used because the CLI pre-populates them. Closes #875
1 parent c9c00d6 commit ce6a22d

File tree

2 files changed

+26
-7
lines changed

2 files changed

+26
-7
lines changed

cli.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -165,13 +165,6 @@ api.on('test-run', function (runStatus) {
165165
});
166166

167167
var files = cli.input.length ? cli.input : arrify(conf.files);
168-
if (files.length === 0) {
169-
files = [
170-
'test.js',
171-
'test-*.js',
172-
'test'
173-
];
174-
}
175168

176169
if (cli.flags.watch) {
177170
try {

test/ava-files.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,3 +104,29 @@ test('findFiles - does not return duplicates of the same file', function (t) {
104104
t.end();
105105
});
106106
});
107+
108+
test('findFiles - finds the correct files by default', function (t) {
109+
var avaFiles = new AvaFiles(['**/ava-files/default-patterns/**']);
110+
var filesToFind = [
111+
'sub/directory/__tests__/foo.js',
112+
'sub/directory/bar.test.js',
113+
'test-foo.js',
114+
'test.js',
115+
'test/baz.js'
116+
];
117+
118+
avaFiles.findTestFiles().then(function (files) {
119+
var allFilesFound = filesToFind.every(function(fileToFind) {
120+
return files.some(function(file) {
121+
return endsWith(file, fileToFind)
122+
});
123+
});
124+
t.true(allFilesFound);
125+
t.is(files.length, 5);
126+
t.end();
127+
});
128+
});
129+
130+
function endsWith(str, suffix) {
131+
return str.indexOf(suffix, str.length - suffix.length) !== -1;
132+
}

0 commit comments

Comments
 (0)