Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gherkin-formatter

Package Overview
Dependencies
Maintainers
6
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gherkin-formatter

Tool to format gherkin-ast model to gherkin string

  • 1.2.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
10K
increased by8.55%
Maintainers
6
Weekly downloads
 
Created
Source

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

Keywords

FAQs

Package last updated on 04 Dec 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc