Socket
Socket
Sign inDemoInstall

gherkin

Package Overview
Dependencies
Maintainers
3
Versions
98
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gherkin - npm Package Compare versions

Comparing version 3.2.0 to 4.0.0

lib/gherkin/dialects.js

3

index.js

@@ -18,4 +18,5 @@ (function (root, factory) {

AstBuilder: require('./lib/gherkin/ast_builder'),
Compiler: require('./lib/gherkin/pickles/compiler')
Compiler: require('./lib/gherkin/pickles/compiler'),
DIALECTS: require('./lib/gherkin/dialects')
};
}));

@@ -37,3 +37,3 @@ var AstNode = require('./ast_node');

this.getResult = function () {
return currentNode().getSingle('Feature');
return currentNode().getSingle('GherkinDocument');
};

@@ -198,3 +198,3 @@

var description = getDescription(examplesNode);
var rows = getTableRows(examplesNode)
var exampleTable = examplesNode.getSingle('Examples_Table')

@@ -208,5 +208,12 @@ return {

description: description,
tableHeader: rows[0],
tableBody: rows.slice(1)
tableHeader: exampleTable != undefined ? exampleTable.tableHeader : undefined,
tableBody: exampleTable != undefined ? exampleTable.tableBody : undefined
};
case 'Examples_Table':
var rows = getTableRows(node)
return {
tableHeader: rows != undefined ? rows[0] : undefined,
tableBody: rows != undefined ? rows.slice(1) : undefined
};
case 'Description':

@@ -230,4 +237,6 @@ var lineTokens = node.getTokens('Other');

if(!featureLine) return null;
var children = []
var background = node.getSingle('Background');
var scenariodefinitions = node.getItems('Scenario_Definition');
if(background) children.push(background);
children = children.concat(node.getItems('Scenario_Definition'));
var description = getDescription(header);

@@ -244,4 +253,10 @@ var language = featureLine.matchedGherkinDialect;

description: description,
background: background,
scenarioDefinitions: scenariodefinitions,
children: children,
};
case 'GherkinDocument':
var feature = node.getSingle('Feature');
return {
type: node.ruleType,
feature: feature,
comments: comments

@@ -248,0 +263,0 @@ };

@@ -2172,2 +2172,3 @@ {

"Функция",
"Функциональность",
"Функционал",

@@ -2174,0 +2175,0 @@ "Свойство"

@@ -1,17 +0,20 @@

var dialects = require('../gherkin-languages.json');
var countSymbols = require('../count_symbols')
function Compiler() {
this.compile = function (feature, path) {
this.compile = function (gherkin_document, path) {
var pickles = [];
var dialect = dialects[feature.language];
if (gherkin_document.feature == null) return pickles;
var feature = gherkin_document.feature;
var featureTags = feature.tags;
var backgroundSteps = getBackgroundSteps(feature.background, path);
var backgroundSteps = [];
feature.scenarioDefinitions.forEach(function (scenarioDefinition) {
if(scenarioDefinition.type === 'Scenario') {
compileScenario(featureTags, backgroundSteps, scenarioDefinition, dialect, path, pickles);
feature.children.forEach(function (scenarioDefinition) {
if(scenarioDefinition.type === 'Background') {
backgroundSteps = pickleSteps(scenarioDefinition, path);
} else if(scenarioDefinition.type === 'Scenario') {
compileScenario(featureTags, backgroundSteps, scenarioDefinition, path, pickles);
} else {
compileScenarioOutline(featureTags, backgroundSteps, scenarioDefinition, dialect, path, pickles);
compileScenarioOutline(featureTags, backgroundSteps, scenarioDefinition, path, pickles);
}

@@ -22,3 +25,5 @@ });

function compileScenario(featureTags, backgroundSteps, scenario, dialect, path, pickles) {
function compileScenario(featureTags, backgroundSteps, scenario, path, pickles) {
if (scenario.steps.length == 0) return;
var steps = [].concat(backgroundSteps);

@@ -34,3 +39,3 @@

tags: pickleTags(tags, path),
name: scenario.keyword + ": " + scenario.name,
name: scenario.name,
locations: [pickleLocation(scenario.location, path)],

@@ -42,5 +47,6 @@ steps: steps

function compileScenarioOutline(featureTags, backgroundSteps, scenarioOutline, dialect, path, pickles) {
var keyword = dialect.scenario[0];
scenarioOutline.examples.forEach(function (examples) {
function compileScenarioOutline(featureTags, backgroundSteps, scenarioOutline, path, pickles) {
if (scenarioOutline.steps.length == 0) return;
scenarioOutline.examples.filter(function(e) { return e.tableHeader != undefined; }).forEach(function (examples) {
var variableCells = examples.tableHeader.cells;

@@ -54,6 +60,6 @@ examples.tableBody.forEach(function (values) {

var stepText = interpolate(scenarioOutlineStep.text, variableCells, valueCells);
var arguments = createPickleArguments(scenarioOutlineStep.argument, variableCells, valueCells, path);
var args = createPickleArguments(scenarioOutlineStep.argument, variableCells, valueCells, path);
var pickleStep = {
text: stepText,
arguments: arguments,
arguments: args,
locations: [

@@ -68,3 +74,3 @@ pickleLocation(values.location, path),

var pickle = {
name: keyword + ": " + interpolate(scenarioOutline.name, variableCells, valueCells),
name: interpolate(scenarioOutline.name, variableCells, valueCells),
steps: steps,

@@ -121,10 +127,6 @@ tags: pickleTags(tags, path),

function getBackgroundSteps(background, path) {
if(background) {
return background.steps.map(function (step) {
return pickleStep(step, path);
});
} else {
return [];
}
function pickleSteps(scenarioDefinition, path) {
return scenarioDefinition.steps.map(function (step) {
return pickleStep(step, path);
});
}

@@ -131,0 +133,0 @@

@@ -1,2 +0,2 @@

var dialects = require('./gherkin-languages.json');
var DIALECTS = require('./dialects');
var Errors = require('./errors');

@@ -14,3 +14,3 @@ var LANGUAGE_PATTERN = /^\s*#\s*language\s*:\s*([a-zA-Z\-_]+)\s*$/;

function changeDialect(newDialectName, location) {
var newDialect = dialects[newDialectName];
var newDialect = DIALECTS[newDialectName];
if(!newDialect) {

@@ -17,0 +17,0 @@ throw Errors.NoSuchLanguageException.create(newDialectName, location);

{
"name": "gherkin",
"version": "3.2.0",
"version": "4.0.0",
"description": "Gherkin parser",

@@ -24,8 +24,6 @@ "main": "index.js",

"devDependencies": {
"bower": "^1.7.2",
"browserify": "^12.0.2",
"browserify": "^13.0.0",
"mocha": "^2.3.4",
"mversion": "^1.10.1",
"uglify-js": "^2.6.1"
}
}

@@ -11,11 +11,13 @@ var assert = require('assert');

assert.deepEqual(ast, {
type: 'Feature',
tags: [],
location: { line: 1, column: 1 },
language: 'en',
keyword: 'Feature',
name: 'hello',
description: undefined,
background: undefined,
scenarioDefinitions: [],
type: 'GherkinDocument',
feature: {
type: 'Feature',
tags: [],
location: { line: 1, column: 1 },
language: 'en',
keyword: 'Feature',
name: 'hello',
description: undefined,
children: []
},
comments: []

@@ -32,23 +34,27 @@ });

assert.deepEqual(ast1, {
type: 'Feature',
tags: [],
location: { line: 1, column: 1 },
language: 'en',
keyword: 'Feature',
name: 'hello',
description: undefined,
background: undefined,
scenarioDefinitions: [],
type: 'GherkinDocument',
feature: {
type: 'Feature',
tags: [],
location: { line: 1, column: 1 },
language: 'en',
keyword: 'Feature',
name: 'hello',
description: undefined,
children: []
},
comments: []
});
assert.deepEqual(ast2, {
type: 'Feature',
tags: [],
location: { line: 1, column: 1 },
language: 'en',
keyword: 'Feature',
name: 'hello again',
description: undefined,
background: undefined,
scenarioDefinitions: [],
type: 'GherkinDocument',
feature: {
type: 'Feature',
tags: [],
location: { line: 1, column: 1 },
language: 'en',
keyword: 'Feature',
name: 'hello again',
description: undefined,
children: []
},
comments: []

@@ -58,3 +64,3 @@ });

it("parses feature after parse error", function () {
it.only("parses feature after parse error", function () {
var parser = new Gherkin.Parser(new Gherkin.AstBuilder());

@@ -77,29 +83,32 @@ var matcher = new Gherkin.TokenMatcher();

matcher);
console.log(JSON.stringify(ast, null, 2))
assert.deepEqual(ast, {
type: 'Feature',
tags: [],
location: { line: 1, column: 1 },
language: 'en',
keyword: 'Feature',
name: 'Foo',
description: undefined,
background: undefined,
scenarioDefinitions: [{
type: 'GherkinDocument',
feature: {
type: 'Feature',
tags: [],
location: {line: 1, column: 1},
language: 'en',
keyword: 'Feature',
name: 'Foo',
description: undefined,
keyword: 'Scenario',
location: { line: 2, column: 3 },
name: 'Bar',
steps: [{
argument: {
content: 'closed docstring',
location: { line: 4, column: 7 },
type: 'DocString',
},
keyword: 'Given ',
location: { line: 3, column: 5 },
text: 'x',
type: 'Step' }],
tags: [],
type: 'Scenario' }],
children: [{
description: undefined,
keyword: 'Scenario',
location: {line: 2, column: 3},
name: 'Bar',
steps: [{
argument: {
content: 'closed docstring',
location: {line: 4, column: 7},
type: 'DocString',
},
keyword: 'Given ',
location: {line: 3, column: 5},
text: 'x',
type: 'Step' }],
tags: [],
type: 'Scenario' }]
},
comments: []

@@ -115,11 +124,13 @@ });

assert.deepEqual(ast, {
type: 'Feature',
tags: [],
location: { line: 1, column: 1 },
language: 'no',
keyword: 'Egenskap',
name: 'i18n support',
description: undefined,
background: undefined,
scenarioDefinitions: [],
type: 'GherkinDocument',
feature: {
type: 'Feature',
tags: [],
location: { line: 1, column: 1 },
language: 'no',
keyword: 'Egenskap',
name: 'i18n support',
description: undefined,
children: []
},
comments: []

@@ -126,0 +137,0 @@ });

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

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