Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gherking/gherkin-formatter
Tool to format gherkin-ast model to gherkin string
https://github.com/gherking/gherkin-formatter
ast cucumber feature-file formatter gherkin gherking hacktoberfest typescript
Last synced: 18 days ago
JSON representation
Tool to format gherkin-ast model to gherkin string
- Host: GitHub
- URL: https://github.com/gherking/gherkin-formatter
- Owner: gherking
- License: mit
- Created: 2018-03-24T16:35:24.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2024-06-18T04:29:41.000Z (5 months ago)
- Last Synced: 2024-10-15T03:30:01.958Z (about 1 month ago)
- Topics: ast, cucumber, feature-file, formatter, gherkin, gherking, hacktoberfest, typescript
- Language: TypeScript
- Homepage: https://gherking.github.io/gherkin-formatter/
- Size: 751 KB
- Stars: 11
- Watchers: 5
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
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
```