Skip to content

Commit fa6f6b4

Browse files
committed
Respect configured extensions for test files
1 parent 7c660a5 commit fa6f6b4

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

lib/ava-files.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ class AvaFiles {
205205
const initialPatterns = this.files.concat(excludePatterns);
206206

207207
// Like in `api.js`, tests must be `.js` files and not start with `_`
208-
if (path.extname(filePath) !== '.js' || path.basename(filePath)[0] === '_') {
208+
if (!this.extensions.includes(path.extname(filePath).substring(1)) || path.basename(filePath)[0] === '_') {
209209
return false;
210210
}
211211

test/ava-files.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ test('ignores relativeness in patterns', t => {
2525
});
2626

2727
test('testMatcher', t => {
28-
const avaFiles = new AvaFiles({files: ['**/foo*']});
28+
const avaFiles = new AvaFiles({files: ['**/foo*'], extensions: ['js', 'ts']});
2929

3030
function isTest(file) {
3131
t.true(avaFiles.isTest(file), `${file} should be a test`);
@@ -40,6 +40,7 @@ test('testMatcher', t => {
4040
isTest('foo/blah.js');
4141
isTest('bar/foo.js');
4242
isTest('bar/foo-bar/baz/buz.js');
43+
isTest('foo-bar.ts');
4344
notTest('bar/baz/buz.js');
4445
notTest('bar.js');
4546
notTest('bar/bar.js');
@@ -49,6 +50,7 @@ test('testMatcher', t => {
4950
notTest('node_modules/foo.js');
5051
notTest('fixtures/foo.js');
5152
notTest('helpers/foo.js');
53+
notTest('foo-bar.unknown-ext');
5254
t.end();
5355
});
5456

0 commit comments

Comments
 (0)