UNPKG

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