You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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
The text was updated successfully, but these errors were encountered:
The messages protocol includes a ParseError message type, which we do emit, I think we just need to refactor a bit so that the message formatter has a chance to finish before we exit. Will try and get a PR up for this soon.
You'll then be able to see parseError messages in that file.
For more programmatic control, you could implement a custom formatter which listens to the emitted messages and then acts on the parseError ones, something like:
import{Formatter}from'@cucumber/cucumber`class MyFormatter extends Formatter { constructor(options) { super(options) options.eventBroadcaster.on('envelope', (envelope) => {
if (envelope.parseError) {
// do something with parse error
}
}
}
}
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
The text was updated successfully, but these errors were encountered: