UNPKG

@amiceli/vitest-cucumber

Version:

vitest tools to use Gherkin feature in unit tests

25 lines (23 loc) 802 B
const matchFilter = (filterItem, tags) => { if (Array.isArray(filterItem)) { return filterItem.every((item) => tags.has(item)); } return tags.has(filterItem); }; export class Taggable { tags = new Set(); /** * Simple matching filter mostly following the cucumber expression tag rules, * e.g. `[["alpha", "beta"], "vitests", "another"]` * will be equivalent to: * (`@alpha` and `@beta`) or `@vitests` or `@another` */ matchTags(filterItems) { return filterItems.some((filterItem) => matchFilter(filterItem, this.tags)); } shouldBeCalled(options) { return ((options.includeTags.length <= 0 || this.matchTags(options.includeTags) === true) && this.matchTags(options.excludeTags) === false); } }