gplint
Version:
A Gherkin linter/validator written in Javascript.
36 lines • 1.26 kB
JavaScript
import _ from 'lodash';
import * as gherkinUtils from './utils/gherkin.js';
import { featureSpread } from './utils/gherkin.js';
export const name = 'no-scenario-outlines-without-examples';
export function run({ feature }) {
if (!feature) {
return [];
}
const errors = [];
featureSpread(feature).children.forEach(child => {
if (child.scenario) {
const { scenario } = child;
const nodeType = gherkinUtils.getNodeType(scenario, feature.language);
if (nodeType === 'Scenario Outline' && (!_.find(scenario.examples, 'tableBody')?.tableBody.length)) {
errors.push({
message: 'Scenario Outline does not have any Examples',
rule: name,
line: scenario.location.line,
column: scenario.location.column,
});
}
}
});
return errors;
}
export const documentation = {
description: 'Disallows scenario outlines without examples.',
examples: [{
title: 'Example',
description: 'Enable rule',
config: {
[name]: 'error',
}
}],
};
//# sourceMappingURL=no-scenario-outlines-without-examples.js.map