UNPKG

gherkin-lint

Version:

A Gherkin linter/validator written in javascript

35 lines (28 loc) 815 B
"use strict"; const _ = require('lodash'); const gherkinUtils = require('./utils/gherkin.js'); const rule = 'no-scenario-outlines-without-examples'; function run(feature) { if (!feature) { return []; } let errors = []; feature.children.forEach(child => { if (child.scenario) { const scenario = child.scenario; const nodeType = gherkinUtils.getNodeType(scenario, feature.language); if (nodeType === 'Scenario Outline' && (!_.find(scenario.examples, 'tableBody') || !_.find(scenario.examples, 'tableBody')['tableBody'].length)) { errors.push({ message: 'Scenario Outline does not have any Examples', rule: rule, line: scenario.location.line }); } } }); return errors; } module.exports = { name: rule, run: run };