1.2.2 • Published 4 months ago

gherkin-formatter v1.2.2

Weekly downloads
30
License
MIT
Repository
github
Last release
4 months ago

gherkin-formatter

Downloads Version@npm Version@git CI Docs

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.

In 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

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.

OptionDescriptionDefault
oneTagPerLineShould 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
separateStepGroupsShould step groups (when-then) be separated?false
compactShould empty lines be skipped, removed from the result?false, i.e., there will be empty lines in appropriate places
lineBreakThe line break character(s).null, i.e., it will determine the line-break based on the platform
indentationThe indentation character(s).' ', i.e., it uses two space characters to add indentation where it's appropriate
tagFormatThe tag format to be used (see gherkin-ast.TagFormat.FUNCTIONAL, i.e., the tags will be outputed as @name(value)

Other

For detailed documentation see the TypeDocs documentation.

This package uses debug for logging, use gherkin-formatter to see debug logs:

DEBUG=gherkin-formatter* node my-script.js
1.2.2

4 months ago

1.2.1-beta.9

6 months ago

1.2.0

6 months ago

1.2.0-beta.8

6 months ago

1.2.1

5 months ago

1.1.0

2 years ago

1.1.0-beta.7

2 years ago

1.0.2

2 years ago

1.0.2-beta.2

2 years ago

1.0.3-beta.4

2 years ago

1.0.3-beta.3

2 years ago

1.0.2-beta.1

2 years ago

1.0.3

2 years ago

1.1.0-beta.6

2 years ago

1.1.0-beta.5

2 years ago

1.0.1

3 years ago

1.0.0

3 years ago

0.1.0

5 years ago

0.0.1

6 years ago