UNPKG

@amiceli/vitest-cucumber

Version:

vitest tools to use Gherkin feature in unit tests

37 lines (36 loc) 1.09 kB
import { StepAble } from './Stepable'; export class Scenario extends StepAble { description; constructor(description, title = 'Scenario') { super(title); this.description = description; } getTitle() { return `${this.title}: ${this.description}`; } } export class ScenarioOutline extends Scenario { examples = []; missingExamplesKeyword = false; constructor(description, title = 'Scenario Outline') { super(description, title); } getStepTitle(step, example) { let stepTitle = step.getTitle(); const exampleKeys = Object.keys(example); for (const key of exampleKeys) { stepTitle = stepTitle.replace(`<${key}>`, example[key]); } return stepTitle; } getStepDocStrings(step, example) { if (step.docStrings) { let docStrings = `${step.docStrings}`; for (const key in example) { docStrings = docStrings.replace(`<${key}>`, example[key]); } return docStrings; } return null; } }