UNPKG

653 BJavaScriptView Raw
1var _ = require("lodash");
2
3module.exports = function(tests, tags) {
4 // Tidy up tag input. If we have a comma-delimited list, tokenize and clean it up
5 if (typeof tags === "string") {
6 tags = tags.split(',').map(_.method('trim'));
7 }
8
9 // If tags are empty or malformed, ignore them
10 if (!_.isArray(tags) || tags.length === 0) {
11 console.log("Mocha tag filter input tags are empty, returning all tests.");
12 return tests;
13 }
14
15 console.log("Using mocha tag filter with tags: ", tags);
16 return tests.filter(function(test) {
17 return tags.every(function(wantedTag) {
18 return test.name.indexOf('@' + wantedTag) > -1;
19 })
20 });
21};