Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const electron = require('electron')
const Convert = require('ansi-to-html')
const convert = new Convert()
const Cucumber = require('cucumber')
// HACK:
// window.Gherkin !== require('gherkin') in browsers, so parsing fails unless:
require('gherkin').Parser = window.Gherkin.Parser
require('gherkin').Compiler = window.Gherkin.Compiler
require('gherkin').DIALECTS = window.Gherkin.DIALECTS
const cli = require('./cli')(electron.remote.process.argv)
function log() {
const args = [].slice.apply(arguments)
const htmlSafeOutput = args[0].toString().replace(//g, '>')
const pre = document.createElement('pre')
pre.innerHTML = convert.toHtml(htmlSafeOutput, { fg: '#000', bg: '#fff' })
document.body.appendChild(pre)
}
const PrettyFormatter = Cucumber.Listener.PrettyFormatter
Cucumber.Listener.PrettyFormatter = function(options) {
options.logToFunction = log
return PrettyFormatter(options)
var _ = require('lodash');
var languageMapping = require('gherkin').DIALECTS;
var rule = 'indentation';
var availableConfigs = {
'Feature': 0,
'Background': 0,
'Scenario': 0,
'Step': 2,
'given': 2,
'when': 2,
'then': 2,
'and': 2,
'but': 2
};
var errors = [];
getScenarioKeyword: function() {
return Gherkin.DIALECTS[self.getLanguage()].scenario;
},
hasOutcomeStepKeyword: function hasOutcomeStepKeyword() {
var language = self.getScenario().getFeature().getLanguage();
return _.chain(Gherkin.DIALECTS[language].then)
.includes(self.getKeyword())
.value();
},
constructor(options) {
const {
backgroundStepLines,
feature,
gherkinData,
language,
lineToDescriptionMapping,
stepLineToKeywordMapping
} = options
this.feature = feature
this.keyword = _.first(Gherkin.DIALECTS[language].scenario)
this.lines = _.map(gherkinData.locations, 'line')
this.name = gherkinData.name
this.tags = _.map(gherkinData.tags, Tag.build)
this.uri = feature.uri
this.line = _.first(this.lines)
this.description = _.chain(this.lines)
.map(line => lineToDescriptionMapping[line])
.compact()
.first()
.value()
let previousStep
this.steps = _.map(gherkinData.steps, gherkinStepData => {
const step = new Step({
backgroundLines: backgroundStepLines,
hasRepeatStepKeyword: function hasRepeatStepKeyword() {
var language = self.getScenario().getFeature().getLanguage();
return _.chain(Gherkin.DIALECTS[language].and)
.concat(Gherkin.DIALECTS[language].but)
.includes(self.getKeyword())
.value();
},