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

How can i attach the Json API response in the report

Open praneshvgaikwad opened this issue 1 year ago • 2 comments

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)) })

praneshvgaikwad avatar Feb 12 '24 15:02 praneshvgaikwad

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

varshanharshank avatar Mar 15 '24 16:03 varshanharshank

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

include the above method in the step definition.

varshanharshank avatar Mar 26 '24 02:03 varshanharshank