From e39b4bdc3a43d8438c15ff4f1e6236cb1d8464de Mon Sep 17 00:00:00 2001 From: Oleksandr Shevtsov Date: Wed, 29 Jun 2022 19:22:34 +0300 Subject: [PATCH] fix: handle background section for new cucumber preprocessor format, address #139 --- reporter/allure-cypress/CucumberHandler.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/reporter/allure-cypress/CucumberHandler.js b/reporter/allure-cypress/CucumberHandler.js index d1bd9f9..5539706 100644 --- a/reporter/allure-cypress/CucumberHandler.js +++ b/reporter/allure-cypress/CucumberHandler.js @@ -31,7 +31,9 @@ module.exports = class CucumberHandler { return ( this.state.currentScenario || this.state.gherkinDocument.feature.children.find((child) => - this.state.pickle.astNodeIds.includes(child.scenario.id) + this.state.pickle.astNodeIds.includes( + child.scenario && child.scenario.id + ) ).scenario ); } @@ -46,7 +48,10 @@ module.exports = class CucumberHandler { get outlineExampleIndex() { if (this.isNewFormat) { const [, exampleId] = this.state.pickle.astNodeIds; - if (!this.currentScenario.examples.length) { + if ( + !this.currentScenario.examples || + !this.currentScenario.examples.length + ) { return -1; } return this.currentScenario.examples[0].tableBody.findIndex( @@ -66,7 +71,7 @@ module.exports = class CucumberHandler { const currentTags = this.currentScenario.tags || []; if (this.isNewFormat) { const indexOfChild = this.feature.children.findIndex( - (child) => child.scenario.id === scenarioId + (child) => child.scenario && child.scenario.id === scenarioId ); if (indexOfChild === -1) { return;