Skip to content

Programmatic API

Import the engines and call them directly in your own code:

import { parse, validate, diff } from 'gherkin-cli'

Each reads .feature source and returns a plain structured result with a pre-computed summary you can act on without a second pass. They write to no stream and never exit the process, so you can call them anywhere — inside a build tool, a test, an editor plugin — without touching your stdout or killing your process.

  • Files are returned in input order; scenarios in document order.
  • Ids come from a deterministic incrementing generator, so repeat runs over the same input return byte-identical structures.
  • No engine mutates its inputs or reaches for ambient state beyond the filesystem (and git, for diff, through an injectable reader).
  • parse — project a suite into a compact scenario/tag/count digest.
  • validate — check .feature well-formedness.
  • diff — classify scenario changes against a git base.