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

gherkin-assembler

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gherkin-assembler

Assembling Gherkin ASTs to feature file string

  • 2.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
20K
increased by1.09%
Maintainers
1
Weekly downloads
 
Created
Source

gherkin-assembler

Build Status dependency Status devDependency Status Coverage Status

It allows to convert Gherkin AST to feature file string.

API

objectToAST(document)

The objectToAST API method converts the given Gherkin object into GherkinDocument object.

A complete sample Gherkin object can be found here: Complete Gherkin object.

Params:

  • {Object} documet - a single Gherkin object

Returns: {GherkinDocument}

format(document, options)

The format API method formats the given Gherkin Document(s) to string (which could be written out to feature file(s)).

Params:

  • {GherkinDocument|Array<GherkinDocument>} document - a single or multiple Gherkin Documents given in it's AST model.
  • {FormatConfig} options - options to set attributes of formatting.

Returns: {string|Array<string>}

'use strict';

const fs = require('fs');
const assembler = require('gherkin-assembler');
const document = assembler.objectToAST(require('./login.ast.json'));

fs.writeFileSync('./login.feature', assembler.format(document), 'utf8');

FormatConfig

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

OptionDescriptionDefault
oneTagPerLineShould tags rendered separately, one by line?false, i.e. all tag 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).\n, i.e. it uses Unix line break, to set Windows style, set \r\n
indentationThe indentation character(s).' ', i.e. it uses two space character to add indentation where it's appropriate

Parsing feature files to Gherkin object

Although this package does not contain method to parse feature file to Gherkin object, you can use the gherkin subpackage of CucumberJS.

'use strict';
const fs = require('fs');
const {Parser} = require('gherkin');
const parser = new Parser();
const document = parser.parse(fs.readFileSync('./login.feature'));

// use objectToAST and format to write it to file again

Keywords

FAQs

Package last updated on 23 Mar 2018

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