UNPKG

@mmisty/cypress-grep

Version:

Filters tests by tags/title using substring or regular expressions (can find dynamic tags)

29 lines (28 loc) 1.35 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.taskWrite = void 0; const fs_1 = require("fs"); const logs_1 = require("../common/logs"); /** * 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: ${config.env['originalSpecPattern']}`); console.log(`${logs_1.pkgName} file with results written: '${filteredSpecsFile}'`); return null; }, }); exports.taskWrite = taskWrite;