UNPKG

741 BJavaScriptView Raw
1// Filter by "group", which really means filename prefix, i.e:
2//
3// --group=test/groupname
4// --group=test/abc/xyz/Regression
5// --group=test/abc/xyz/Smoke
6//
7var path = require('path');
8
9module.exports = function(tests, partialFilename) {
10 if (!partialFilename) {
11 console.log('No partial filename supplied to group filter, using all tests');
12 return tests;
13 }
14
15 if (typeof partialFilename === 'string') {
16 partialFilename = [partialFilename];
17 }
18
19 console.log("Using group filter: ", partialFilename);
20 return tests.filter(function(t) {
21 return path.extname(t.filename) === '.js';
22 }).filter(function(t) {
23 return partialFilename.some(function(pfn) {
24 return t.filename.indexOf(pfn) !== -1;
25 });
26 });
27};