UNPKG

@amiceli/vitest-cucumber

Version:

vitest tools to use Gherkin feature in unit tests

56 lines (55 loc) 2.19 kB
export function defineRuleScenarioToRun(options) { const describeToRun = options.describes.filter((d) => !d.skipped && !d.only); const describeToSkip = options.describes.filter((d) => d.skipped && !d.only); const onlyDescribeToRun = options.describes.filter((d) => !d.skipped && d.only); const finalDescribesToRun = []; for (const toRun of describeToRun) { if (options.featureBackground) { if (options.featureBackground.skipped) { describeToSkip.push(options.featureBackground); } else { finalDescribesToRun.push(options.featureBackground); } } if (options.ruleBackground) { if (options.ruleBackground.skipped) { describeToSkip.push(options.ruleBackground); } else { finalDescribesToRun.push(options.ruleBackground); } } finalDescribesToRun.push(toRun); } return { describeToRun: finalDescribesToRun, describeToSkip, onlyDescribeToRun, }; } export function defineScenarioToRun(options) { const describeToRun = options.describes.filter((d) => !d.skipped && !d.only); const describeToSkip = options.describes.filter((d) => d.skipped && !d.only); const onlyDescribeToRun = options.describes.filter((d) => !d.skipped && d.only); const finalDescribesToRun = []; for (const toRun of describeToRun) { if (options.featureBackground) { if (options.featureBackground.skipped) { describeToSkip.push(options.featureBackground); } else { finalDescribesToRun.push(options.featureBackground); } } finalDescribesToRun.push(toRun); } describeToSkip.push(...options.describeRules.filter((s) => s.skipped && !s.only)); finalDescribesToRun.push(...options.describeRules.filter((s) => !s.skipped && !s.only)); onlyDescribeToRun.push(...options.describeRules.filter((s) => !s.skipped && s.only)); return { describeToRun: finalDescribesToRun, describeToSkip, onlyDescribeToRun, }; }