# gherkin-io

> Tool to read/write Gherkin feature files and work with Gherking AST

Latest version **1.3.0** (published 2023-11-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install gherkin-io
pnpm add gherkin-io
yarn add gherkin-io
bun add gherkin-io
```

## Health

**Score 45/100 (D)** — status: abandoned.

Positive: has types; no vulnerabilities; has provenance; high maintenance score; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 1.3.0 |
| Published | 2023-11-12 |
| First published | 2018-05-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=12.0.0 |
| Dependencies | 7 |
| Unpacked size | 13 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 3 |
| Author | GherKing |
| Maintainers | monikalaszlo, rakur, wgula, szikszail, judit-nahaj, sorosz89 |
| Keywords | Gherkin, Feature, Scenario, Scenario Outline, Background, Step, Examples |

## Links

- npm: https://www.npmjs.com/package/gherkin-io
- Repository: https://github.com/gherking/gherkin-io
- Homepage: https://github.com/gherking/gherkin-io#readme
- Issues: https://github.com/gherking/gherkin-io/issues
- npm.io page: https://npm.io/package/gherkin-io

## Dependencies (7)

- [glob](https://npm.io/package/glob.md) ^10.3.10
- [debug](https://npm.io/package/debug.md) ^4.3.4
- [fs-extra](https://npm.io/package/fs-extra.md) ^11.1.1
- [gherkin-ast](https://npm.io/package/gherkin-ast.md) ^3.4.0
- [@cucumber/gherkin](https://npm.io/package/@cucumber/gherkin.md) ^27.0.0
- [gherkin-formatter](https://npm.io/package/gherkin-formatter.md) ^1.2.0
- [@cucumber/gherkin-streams](https://npm.io/package/@cucumber/gherkin-streams.md) ^5.0.1

## Recent versions

- 1.3.0 (latest) — 2023-11-12
- 1.3.0-beta.2 (beta) — 2023-11-12
- 1.2.0 — 2023-07-31
- 1.1.3 — 2022-10-18
- 1.2.0-beta.1 — 2022-02-21
- 1.1.2 — 2022-01-10
- 1.1.1 — 2021-11-30
- 1.1.0 — 2021-09-20
- 1.0.3 — 2021-03-25
- 1.0.2 — 2021-03-25
- 1.0.1 — 2021-03-25
- 0.1.1 — 2020-06-24
- 0.0.1 — 2018-05-11

## README

# gherkin-io

![Downloads](https://img.shields.io/npm/dw/gherkin-io?style=flat-square)
![Version@npm](https://img.shields.io/npm/v/gherkin-io?label=version%40npm&style=flat-square)
![Version@git](https://img.shields.io/github/package-json/v/gherking/gherkin-io/master?label=version%40git&style=flat-square)
![CI](https://img.shields.io/github/actions/workflow/status/gherking/gherkin-io/ci.yml?branch=master&label=ci&style=flat-square)
![Docs](https://img.shields.io/github/actions/workflow/status/gherking/gherkin-io/docs.yml?branch=master&label=docs&style=flat-square)

Tool to read/write Gherkin feature files and work with Gherking AST

## Usage

### Parse feature string

The `parse` function can be used to parse feature file content to [AST](https://github.com/gherking/gherkin-io).

```typescript
function parse(content: string, uri: string): Promise<Document>
```

In TypeScript:

```typescript
import {parse, Document} from "gherkin-io";
import {TagFormat} from "gherkin-ast";

const document: Document = await parse(
    "Feature: Test\n...",
    "./features/test.feature",
    {tagFormat: TagFormat.FUNCTIONAL} // default
);
```

In JavaScript:
```javascript
const {parse} = require("gherkin-io");
const {TagFormat} = require("gherkin-ast");
const document = await read(
    "Feature: Test\n...", 
    "./features/test.feature", 
    {tagFormat: TagFormat.FUNCTIONAL} // default
);
```

### Read feature files

The `read` function can be used to parse feature file(s) to [AST](https://github.com/gherking/gherkin-io).

```typescript
function read(pattern: string): Promise<Document[]>
```

In TypeScript:
```typescript
import {read, Document} from "gherkin-io";
import {TagFormat} from "gherkin-ast";

const documents: Document[] = await read(
    "./features/*.feature",
    {tagFormat: TagFormat.FUNCTIONAL} // default
);
```

In JavaScript:
```javascript
const {read} = require("gherkin-io");
const {TagFormat} = require("gherkin-ast");
const documents = await read(
    "./features/*.feature",
    {tagFormat: TagFormat.FUNCTIONAL} // default
);
```

### Write feature files

The `write` function can be used to write an AST to a feature file.

```typescript
function write(filePath: string, document: Document, options?: FormatterOptions): Promise<void>
```

In TypeScript:
```typescript
import {Document, write, FormatterOptions} from "gherkin-io";
const document: Document = new Document(/*...*/);
const options: FormatterOptions = {/*...*/};
await write("./test.feature", document, options);
```

In JavaScript:
```javascript
const {write, Document} = require("gherkin-io");
const document = new Document(/*...*/);
const options = {/*...*/};
await write("./test.feature", document, options);
```

`FormatterOptions` is re-exported from [gherkin-formatter](https://github.com/gherking/gherkin-formatter).

For detailed documentation see the [TypeDocs documentation](https://gherking.github.io/gherkin-io/).

---
_Source: https://npm.io/package/gherkin-io · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
