WasiqB / multiple-cucumber-html-reporter

Generate beautiful Cucumber HTML reports
https://github.com/WasiqB/multiple-cucumber-html-reporter/blob/main/README.md
MIT License
247 stars 115 forks source link

How can i attach the Json API response in the report #321

Open praneshvgaikwad opened 6 months ago

praneshvgaikwad commented 6 months ago

I am using Playwright + Typescript + BDD framework where i need to attach the Json response from one of the method to the report. Not sure how i can attach the json.

When('User approves the Payment of amount {string} and validates the API response for Payment approval', async function (amount) { let apiResp = { apiURL: 'API URL', apiResponse: 'Response Body' } apiResp = await paymentsPage.userApprovesThePayment(paymentDescription, amount) const url: string = apiResp.apiURL const responseBdy: string = apiResp.apiResponse await this.log(btoa('The API response validated for URL: ' +url)) })

varshanharshank commented 5 months ago

i am also facing the same issue, unable to attach API request and resposne

varshanharshank commented 5 months ago

@praneshvgaikwad this. attach(JSON.stringfy(data), 'application/json)

include the above method in the step definition.