import { Query as GherkinQuery } from '@cucumber/gherkin-utils' ; import { Query as CucumberQuery } from '@cucumber/query' ; import * as messages from '@cucumber/messages' ; import { GherkinDocumentWalker , rejectAllFilters } from '@cucumber/gherkin-utils' ; import { getWorstTestStepResult } from '@cucumber/messages' ; export default function filterByStatus ( gherkinDocument , gherkinQuery , cucumberQuery , statuses ) { const filters = { acceptScenario : ( scenario ) => { const pickleIds = gherkinQuery . getPickleIds ( gherkinDocument . uri , scenario . id ) ; return pickleIds . map ( ( pickleId ) => statuses . includes ( getWorstTestStepResult ( cucumberQuery . getPickleTestStepResults ( [ pickleId ] ) ) . status ) ) . includes ( true ) ; } , } ; const walker = new GherkinDocumentWalker ( { ... rejectAllFilters , ... filters , } ) ; return walker . walkGherkinDocument ( gherkinDocument ) ; }