# gherkin-formatter

> Tool to format gherkin-ast model to gherkin string

Latest version **1.2.2** (published 2024-01-22) · MIT license · 0 weekly downloads

## Install

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

## 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.2.2 |
| Published | 2024-01-22 |
| First published | 2018-03-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=12.0.0 |
| Dependencies | 5 |
| Unpacked size | 46.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 12 |
| Author | GherKing |
| Maintainers | monikalaszlo, rakur, wgula, szikszail, judit-nahaj, sorosz89 |
| Keywords | Gherkin, Feature, Scenario, Scenario Outline, Background, Step, Examples, AST |

## Links

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

## Dependencies (5)

- [debug](https://npm.io/package/debug.md) ^4.3.4
- [table](https://npm.io/package/table.md) ^6.8.1
- [tslib](https://npm.io/package/tslib.md) ^2.6.2
- [gherkin-ast](https://npm.io/package/gherkin-ast.md) ^3.4.1
- [lines-builder](https://npm.io/package/lines-builder.md) ^1.5.1

## Alternatives

- [update-check](https://npm.io/package/update-check.md) — 4.0M weekly downloads
- [react-native-onesignal](https://npm.io/package/react-native-onesignal.md) — 134.5K weekly downloads
- [react-redux-toastr](https://npm.io/package/react-redux-toastr.md) — 33.7K weekly downloads
- [@nocobase/plugin-notification-manager](https://npm.io/package/@nocobase/plugin-notification-manager.md) — 2.0K weekly downloads
- [react-simple-toasts](https://npm.io/package/react-simple-toasts.md) — 1.9K weekly downloads

## Recent versions

- 1.2.2 (latest) — 2024-01-22
- 1.2.1-beta.9 (beta) — 2023-11-24
- 1.2.1 — 2023-12-04
- 1.2.0 — 2023-11-11
- 1.2.0-beta.8 — 2023-11-11
- 1.1.0 — 2022-03-15
- 1.1.0-beta.7 — 2022-03-05
- 1.1.0-beta.6 — 2022-02-21
- 1.1.0-beta.5 — 2022-02-21
- 1.0.3 — 2022-01-29
- 1.0.3-beta.4 — 2022-01-24
- 1.0.3-beta.3 — 2022-01-23
- 1.0.2 — 2022-01-10
- 1.0.2-beta.2 — 2022-01-10
- 1.0.2-beta.1 — 2022-01-10
- … 4 more at https://npm.io/package/gherkin-formatter/versions

## README

# gherkin-formatter

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

Tool to format gherkin-ast model to gherkin string

## Usage

The format function of this package provides a formatted string (gherkin document) from
your [AST](https://github.com/gherking/gherkin-ast).

In TypeScript

```typescript
import { format, FormatOptions } from "gherkin-formatter";
import { Document } from "gherkin-ast";
import { read } from "gherkin-io";

const document: Document[] = await read("./test.feature");
const options: FormatOptions = {separateStepGroups: false};
console.log(format(document[0], options));
// Feature: Test Feature
//
//   As a user...
```

In JavaScript

```javascript
const {format, FormatOptions} = require("gherkin-formatter");
const {Document} = require("gherkin-ast");
const {read} = require("gherkin-io");

const document = await read("./test.feature");
const options = {
    separateStepGroups: false
};
console.log(format(document[0], options));
// Feature: Test Feature
//
//   As a user...
```

### Configuration - `FormatConfig`

Passing a `FormatConfig` object to format method (or other Ast type methods where it's applicable), how feature file
text is rendered can be set.

| Option               | Description                                                                            | Default                                                                                |
|:---------------------|:---------------------------------------------------------------------------------------|:---------------------------------------------------------------------------------------|
| `oneTagPerLine`      | Should the tags be rendered separately, one by line?                                   | `false`, i.e., all tags of a scenario, feature, etc. will be rendered in the same line |
| `separateStepGroups` | Should step groups (when-then) be separated?                                           | `false`                                                                                |
| `compact`            | Should empty lines be skipped, removed from the result?                                | `false`, i.e., there will be empty lines in appropriate places                         |
| `lineBreak`          | The line break character(s).                                                           | `null`, i.e., it will determine the line-break based on the platform                   |
| `indentation`        | The indentation character(s).                                                          | `'  '`, i.e., it uses two space characters to add indentation where it's appropriate   | 
| `tagFormat`          | The tag format to be used (see [gherkin-ast](https://github.com/gherking/gherkin-ast). | `TagFormat.FUNCTIONAL`, i.e., the tags will be outputed as `@name(value)`              |

## Other

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

This package uses [debug](https://www.npmjs.com/package/debug) for logging, use `gherkin-formatter` to see debug logs:

```shell
DEBUG=gherkin-formatter* node my-script.js
```

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