cucumber / cucumber-js

Cucumber for JavaScript
https://cucumber.io
MIT License
5.04k stars 1.09k forks source link

Update Test Step Status programmatically #2378

Closed mrsenzy closed 7 months ago

mrsenzy commented 7 months ago

We are not able to use Playwright soft assert feature with cucumberjs library as playwright soft assert are captured with playwright test runner. So, I am trying for custom function to catch the error from playwright expect method and print the result in cucumber report and set step status to Failed when there is exception caught.

I am able to write the error to report.json and generate in cucumber report but i am not able to successfully update step status to failed. May I know if its possible to update step status programmatically and how can it be done. I tried below approach but getting undefined error. TypeError: Cannot set properties of undefined (setting 'status')

stepResult: messages.TestStepResult

async setCucumberError(message: string) { this.takeScreenshot(); this.attach(message, "text/plain") this.stepResult.status = messages.TestStepResultStatus.FAILED }