New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

gherkin-io

Package Overview
Dependencies
Maintainers
6
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gherkin-io

Tool to read/write Gherkin feature files and work with Gherking AST

  • 1.3.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
9K
decreased by-24.73%
Maintainers
6
Weekly downloads
 
Created
Source

gherkin-io

Downloads Version@npm Version@git CI Docs

Tool to read/write Gherkin feature files and work with Gherking AST

Usage

Parse feature string

The parse function can be used to parse feature file content to AST.

function parse(content: string, uri: string): Promise<Document>

In TypeScript:

import {parse, Document} from "gherkin-io";
import {TagFormat} from "gherkin-ast";

const document: Document = await parse(
    "Feature: Test\n...",
    "./features/test.feature",
    {tagFormat: TagFormat.FUNCTIONAL} // default
);

In JavaScript:

const {parse} = require("gherkin-io");
const {TagFormat} = require("gherkin-ast");
const document = await read(
    "Feature: Test\n...", 
    "./features/test.feature", 
    {tagFormat: TagFormat.FUNCTIONAL} // default
);

Read feature files

The read function can be used to parse feature file(s) to AST.

function read(pattern: string): Promise<Document[]>

In TypeScript:

import {read, Document} from "gherkin-io";
import {TagFormat} from "gherkin-ast";

const documents: Document[] = await read(
    "./features/*.feature",
    {tagFormat: TagFormat.FUNCTIONAL} // default
);

In JavaScript:

const {read} = require("gherkin-io");
const {TagFormat} = require("gherkin-ast");
const documents = await read(
    "./features/*.feature",
    {tagFormat: TagFormat.FUNCTIONAL} // default
);

Write feature files

The write function can be used to write an AST to a feature file.

function write(filePath: string, document: Document, options?: FormatterOptions): Promise<void>

In TypeScript:

import {Document, write, FormatterOptions} from "gherkin-io";
const document: Document = new Document(/*...*/);
const options: FormatterOptions = {/*...*/};
await write("./test.feature", document, options);

In JavaScript:

const {write, Document} = require("gherkin-io");
const document = new Document(/*...*/);
const options = {/*...*/};
await write("./test.feature", document, options);

FormatterOptions is re-exported from gherkin-formatter.

For detailed documentation see the TypeDocs documentation.

Keywords

FAQs

Package last updated on 12 Nov 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