Skip to content

Getting the parse error into a variable #1404

@manisshaa

Description

@manisshaa

If the feature file is not in proper gherkin format, Cucumber shows a parse error on console and aborts the tests. Following is the code that does that (this is a snippet from cucumber > lib > cli > run.js

function exitWithError(error) {
console.error(_verror.default.fullStack(error)); // eslint-disable-line no-console
process.exit(1);
}

I want to capture this parse error into a variable or a file. As a work around, I have added a line to function exitWithError to write the parse error to a file for me to later read the error for reporting purposes. But this solution requires my own version of cucumber package and then use the same. But the problem is that my changes will be overwritten once cucumber package is updated.

function exitWithError(error) {
fs.writeFileSync("./Parse_Error", error);
console.error(_verror.default.fullStack(error)); // eslint-disable-line no-console
process.exit(1);
}

Please suggest.

Note: Please know that I need to handle this scenario as we don't manually create cucumber feature files but import them from Jira cucumber tests. These tests are created by stakeholders who may make some minor mistakes in these cucumber tests which may lead to the parse error. I need to capture the parse error (in a file or variable), so that I can report it back to the jira ticket as a comment or something

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions