Save request and response json details in variables #81
-
Hello! This is my code Given(/^Post Notificacion con atributos (.*), (.*), (.*)$/, async function(email, body, petition){
servicio.post('/telematics/v1/notification')
.withHeaders({
'Content-Type': 'application/json',
})
.withJson({ email: email,
body: body,
petition: petition
})
.inspect();
await servicio.toss(); This is a example of request details printed in Terminal by the Inspect() var requestDetail = {
"url": "/telematics/v1/notification",
"method": "POST",
"headers": {
"Content-Type": "application/json",
},
"path": "/telematics/v1/notification",
"body": {
"email": "[email protected]",
"body": "test"
},
"timeout": 3000
}
My goal is save in variables to attach in Cucumber Html Report, How can i do? this.attach(JSON.stringify(requestDetail, null, 2));
this.attach(JSON.stringify(responseDetail, null, 2));
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Hey @Walrusv ! servicio._request // to get the request
servicio._response // to get the response Just add these after the |
Beta Was this translation helpful? Give feedback.
Hey @Walrusv !
Yes,
inspect()
prints the request, response onto terminal/console.You can access the request and response details from spec object with
spec._request
andspec._response
. In your case, it would beJust add these after the
toss()
and you might want to explicitly access parts from_response
(like body, headers).