Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
varshanharshank opened this issue Mar 19, 2024 · 1 comment
Open
Labels

Comments

@varshanharshank
Copy link

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.

@alalama
Copy link

alalama commented May 9, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants