@mmisty/cypress-grep
Version:
Filters tests by tags/title using substring or regular expressions (can find dynamic tags)
31 lines (30 loc) • 1.49 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.taskWrite = void 0;
/// <reference types="cypress" />
const fs_1 = require("fs");
const logs_1 = require("../common/logs");
const public_config_plugin_1 = require("./public-config-plugin");
/**
* Write file with contents (file path predefined)
* @param config - plugin config options
* @param parentFolder - folder relatively to which test ran in prefilter mode
* @param filteredSpecsFile - path to file (set in plugins)
*/
const taskWrite = (config, parentFolder, filteredSpecsFile) => ({
writeTempFileWithSelectedTests: (contents) => {
const result = Object.assign({ parentFolder }, contents);
(0, fs_1.writeFileSync)(filteredSpecsFile, JSON.stringify(result, null, ' '));
const cyan = '\x1b[36m';
const end = '\x1b[0m';
if (contents.tests.length > 0) {
console.log(`${logs_1.pkgName} filtered:\n ${cyan}◌${end} ${contents.tests
.map(t => `${cyan}${`${t.filteredTitle}`.replace(/\/\//g, '/')}${end}`)
.join(`\n ${cyan}◌${end} `)}\n`);
}
console.log(`${logs_1.pkgName} filtered ${contents.tests.length} from total ${contents.total} tests by spec pattern: ${(0, public_config_plugin_1.publicGet)(config, 'originalSpecPattern')}`);
console.log(`${logs_1.pkgName} file with results written: '${filteredSpecsFile}'`);
return null;
},
});
exports.taskWrite = taskWrite;