badeball / cypress-cucumber-preprocessor

Run cucumber/gherkin-syntaxed specs with Cypress
MIT License
1.32k stars 149 forks source link

unable to get cy.log() data on cucumber report #296

Closed sandygit2201 closed 2 years ago

sandygit2201 commented 4 years ago

I am using cypress with cypress-cucumber-process. i am logging some data using cy.log() in side cucumber steps implementation but, on generating cucumber using cypress-multi-reporters module, i am unable to see the data on cucumber report. generated json files under cucumber-json also doesn't contain the data logged using cy.log().

can anyone help me to fix this issue?

Thank you.

pravynandas commented 4 years ago

Try this. After implementing this I get my cy.log() to CI console LOGGER and to the terminal. I hope this will work for report generation too.

... In cypress/plugins/index.js

module.exports = (on, config) => { // on is used to hook into various events Cypress emits // required for .features files on('file:preprocessor', cucumber());

// To bypass cy.log events to LOGGER on('task', { log (message) { console.log(message); return null; } });

// config is the resolved Cypress config // return cypressConfigResolver();

};

... And in cypress/support/commands.js

// -- Overwrite log command to use task instead Cypress.Commands.overwrite('log', (subject, message) => cy.task('log', message));

Courtesy: Comment

Dileep17 commented 4 years ago

@pravynandas with above I couldn't get the log written to json output generated. Not sure if im missing something!

tried finding in documentation but couldn;t find the way to write custom log messages to json output

pravynandas commented 4 years ago

Sorry @Dileep17 I tried the console method alone. Haven't tried the json.

Mahi-Automation commented 3 years ago

@Dileep17 , @pravynandas Any Update on this issue whether got resolved or any workaround?

badeball commented 2 years ago

Due to personal reasons, the previous maintainers of this package are stepping down and handing the reigns over to me, a long-time contributor to the project and a user of it myself. This is a responsibility I'm very excited about. Furthermore, I'd like to thank @lgandecki ++ for all the work that they've done so far.

Read more about the transfer of ownership here.

The repository has however moved and all outstanding issues are being closed. This is not a reflection of the perceived importance of your reported issue. However, if after upgrading to the new version, you still find there to be an issue, feel free to open up another ticket or comment below. Please make sure to read CONTRIBUTING.md before doing so.