Closed RodrigoGambino closed 9 months ago
@RodrigoGambino have you tried to import the attach
method as follows:
const { attach } = require("wdio-cucumberjs-json-reporter")
@christian-bromann I added the import of attach to the code as you indicate, but it still throws the same error.
It appears there may be an issue with the import process. Unfortunately, my ability to assist is limited in this context. I would recommend conducting a thorough debugging to identify and resolve the problem.
@christian-bromann When I check the code
const { attach } = require("wdio-cucumberjs-json-reporter")
I get a message that says ""attach" is declared, but its value is never read".
@RodrigoGambino yes, because you have to use it as such:
- cucumberJson.attach(await browser.takeScreenshot(), 'image/png');
+ attach(await browser.takeScreenshot(), 'image/png');
I will go ahead and close this as I doubt this is an actual bug in the reporter.
@christian-bromann Using only attach instead of cucumberJson to attach a screenshot solved the problem, it was possible to attach the screenshots in each step of the report. Then you should no longer use
cucumberJson.attach(await browser.takeScreenshot(), 'image/png');
because in my case I followed the steps indicated in the report instructions and this error appears, then only
attach(await browser.takeScreenshot(), 'image/png');
is valid.
The report configuration instructions should be updated I think, or not?.
The report configuration instructions should be updated I think, or not?.
Yeah, mind raising a PR for this?
where do I create the branch from main? It seems I don't have permissions to create branches.
@RodrigoGambino please fork the repository and raise a PR from your fork.
Environment (please complete the following information):
Config of webdriver.io and the reporter
const cucumberJson = require("wdio-cucumberjs-json-reporter").default;
Describe the bug I want to add a screenshot to the report in each step of the script, but I get the error "ERROR @wdio/utils:shim: TypeError: Cannot read properties of undefined (reading 'attach')", and I have everything configured as indicated, but I can't find the solution, or what's wrong. The afterStep hook is executed after each step, but at each step the error occurs.
To Reproduce Just add the codes where appropriate in the wdio.conf.ts file.
Expected behavior Add screenshots to each step in the report.
Snapshots
Additional context Add any other context about the problem here.