Security News
NIST Misses 2024 Deadline to Clear NVD Backlog
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.
The gherkin npm package is a parser for the Gherkin language, which is used to write structured tests in a business-readable, domain-specific language. It is commonly used in Behavior-Driven Development (BDD) frameworks like Cucumber.
Parsing Gherkin Syntax
This feature allows you to parse Gherkin syntax into a structured format. The code sample demonstrates how to parse a simple Gherkin feature file and output the resulting JSON structure.
const { Parser } = require('gherkin');
const parser = new Parser();
const gherkinDocument = parser.parse(`
Feature: Example feature
Scenario: Example scenario
Given a precondition
When an action is performed
Then an outcome is expected
`);
console.log(JSON.stringify(gherkinDocument, null, 2));
Tokenizing Gherkin Syntax
This feature allows you to tokenize Gherkin syntax, breaking it down into individual tokens. The code sample demonstrates how to read and print tokens from a Gherkin feature file.
const { TokenScanner, TokenMatcher, GherkinLine, Token } = require('gherkin');
const scanner = new TokenScanner(`
Feature: Example feature
Scenario: Example scenario
Given a precondition
When an action is performed
Then an outcome is expected
`);
const matcher = new TokenMatcher();
let token;
while ((token = scanner.read()) && token.isEOF === false) {
console.log(token);
}
Generating Pickles
This feature allows you to generate 'pickles' from Gherkin documents. Pickles are a simplified, executable representation of Gherkin scenarios. The code sample demonstrates how to parse a Gherkin document and compile it into pickles.
const { Parser, Compiler } = require('gherkin');
const parser = new Parser();
const compiler = new Compiler();
const gherkinDocument = parser.parse(`
Feature: Example feature
Scenario: Example scenario
Given a precondition
When an action is performed
Then an outcome is expected
`);
const pickles = compiler.compile(gherkinDocument);
console.log(JSON.stringify(pickles, null, 2));
Cucumber is a tool for running automated tests written in plain language. It supports the Gherkin syntax and integrates with various programming languages. Compared to gherkin, Cucumber provides a full-fledged testing framework, including test execution and reporting.
FAQs
Gherkin parser
The npm package gherkin receives a total of 921,707 weekly downloads. As such, gherkin popularity was classified as popular.
We found that gherkin demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
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.
Security News
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.
Security News
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
Security News
The Socket Research team breaks down a malicious npm package targeting the legitimate DOMPurify library. It uses obfuscated code to hide that it is exfiltrating browser and crypto wallet data.