multiple-cucumber-html-reporter icon indicating copy to clipboard operation
multiple-cucumber-html-reporter copied to clipboard

Playwright + Cucumber - How to include console.log in the report

Open varshanharshank opened this issue 11 months ago • 1 comments

Environment (please complete the following information):

  • multiple-cucumber-html-reporter:3.6.0
  • Node.js version: [e.g. 8.9.1] - v18.17.1
  • NPM version: [e.g. 5.8.0] - 9.6.7
  • Platform name and version: [e.g. Windows 10] - Mac
  • Cucumber version: [e.g. 4.2.0] - 10.3.0

Config of multiple-cucumber-html-reporter

I used the below code for report configuration

import report = require('multiple-cucumber-html-reporter') report.generate({ jsonDir: 'reports/cucumberReport', reportName: 'Purple Portal Report', reportPath: './reports/cucumberReport', metadata: { browser: { name: '', version: '', }, device: 'Local test machine', platform: { name: '', version: '', }, }, customData: { title: 'Run info', data: [ { label: 'Project', value: 'CRSP' }, { label: 'Application', value: 'Purple Portal' }, ], }, })

Describe the bug In my script, I have included some API calls. I need to print API response in the cucumber report. Example. I have written below function and calling this function one of the step definition and expecting to see the console.log in the report

public async toGetRouterDetails() { try { const config = { method: 'post', url: ApplicationConstants.API.GET_ROUTER_DETAILS_URL, httpsAgent: new https.Agent({ // for self signed you could also add rejectUnauthorized: false, }), } const response = await axios(config) expect(response.status).toEqual(200) getRouterDetailsResponse = await response.data console.log( 'Get RouterDetails Response=====>', JSON.stringify(getRouterDetailsResponse) ) } catch (error) { console.error('Error: ', error.message) console.error('Error Response:', error) throw error } }

To Reproduce Steps to reproduce the behavior:

[Include code or an example repository that can easily be set up]

Expected behavior A clear and concise description of what you expected to happen.

Log If applicable, add logs to help explain your problem. If you don't have logs, enable 'debug:true' in the config and paste the log here. Please use proper markdown to style it

Additional context Add any other context about the problem here.

varshanharshank avatar Mar 19 '24 16:03 varshanharshank

I'm not sure if this suffice for you, but I just attach strings to the steps with an afterstep hook. Checkout Docu on Cucumber attachments: Attachments

alalama avatar May 09 '24 23:05 alalama