Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
module.exports = function Config() {
var parser = new Gherkin.Parser();
var compiler = new Gherkin.Compiler();
this.buildTestCases = function (glue, gherkinLoader) {
var pickles = [];
gherkinLoader.loadGherkinFiles().forEach(function (gherkinFile) {
var feature = parser.parse(gherkinFile.read());
pickles = pickles.concat(compiler.compile(feature));
});
return pickles.map(function (pickle) {
return glue.createTestCase(pickle);
});
}
};
function Parser(featureSources, astFilter) {
var Gherkin = require('gherkin');
var Cucumber = require('../cucumber');
var parser = new Gherkin.Parser();
var compiler = new Gherkin.Compiler();
var self = {
parse: function parse() {
var features = [];
featureSources.forEach(function (featureSource) {
var uri = featureSource[Parser.FEATURE_NAME_SOURCE_PAIR_URI_INDEX];
var source = featureSource[Parser.FEATURE_NAME_SOURCE_PAIR_SOURCE_INDEX];
var gherkinDocument;
try {
gherkinDocument = parser.parse(source);
} catch(e) {
e.message += '\npath: ' + uri;
throw e;
}
import Feature from '../models/feature'
import Gherkin from 'gherkin'
const gherkinCompiler = new Gherkin.Compiler()
const gherkinParser = new Gherkin.Parser()
export default class Parser {
static parse({ scenarioFilter, source, uri }) {
let gherkinDocument
try {
gherkinDocument = gherkinParser.parse(source)
} catch (error) {
error.message += '\npath: ' + uri
throw error
}
if (gherkinDocument.feature) {
return new Feature({
gherkinData: gherkinDocument.feature,
gherkinPickles: gherkinCompiler.compile(gherkinDocument, uri),
module.exports = function PickleLoader(otherFilter) {
var parser = new Gherkin.Parser();
var compiler = new Gherkin.Compiler();
this.loadPickles = function (path) {
var pickles = [];
var lineFilter, paths;
if (exists(path) && fs.statSync(path).isDirectory()) {
paths = glob(path + "/**/*.feature");
lineFilter = passthrough;
} else {
var pathWithLines = new PathWithLines(path);
paths = pathWithLines.paths;
lineFilter = pathWithLines.filter;
}
paths.forEach(function (featurePath) {
var gherkin = fs.readFileSync(featurePath, 'utf-8');