expectBody not working as expected
See original GitHub issueHi @mcollina my version “autocannon”: “^7.9.0”, my codebase
let customResponse= customResponse
url: 'http://localhost:3011/employees/api/searchtype/',
amount: 10,
connections: 1,
pipelining: 1,
//duration: 60,
method: "POST",
debug: true,
expectBody: customResponse,
headers: { "Content-Type": "application/json; charset=UTF-8", 'x-access-token': 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE2NTkxMjMxMTd9.xavjahsbNggTSDBu6Vmsxzz6olPMXHTPggkFForZqaU' },
body: JSON.stringify(customRequest),
}, (err, result) => {
console.log(err);
if (err != null) return; // or do some error handling
handleResults(result);
})
The response which i am getting from api response is below API Response
and when I compare it http://www.jsondiff.com/ it was identical Problem statement
when i run the above i am getting mismatched results which should not happen if both the customResponse and API Response are identical
Any pointers on how to tackle this issue
Issue Analytics
- State:
- Created a year ago
- Comments:11 (4 by maintainers)
Top Results From Across the Web
WebTestClientExtensions.expectBody doesn't work ... - GitHub
Since WebTestClientExtensions.expectBody uses plain Class instead of ParameterizedTypeReference , it cannot correctly deserialize generic types.
Read more >WebTestClient check that jsonPath contains sub string
I am using Spring Boot 2.7.5 and this works just fine. The currently selected correct answer might work but it is much more...
Read more >WebTestClient$BodyContentSpec.jsonPath - Java - Tabnine
Assert the response body content with the given Consumer. json. Parse the expected and actual response content as JSON and perform a "lenient"...
Read more >WebTestClient.ResponseSpec (Spring Framework 6.0.3 API)
Consume and decode the response body to a single object of type <B> and then apply assertions. Parameters: bodyType - the expected body...
Read more >What To Expect - Body Gears Physical TherapyBody Gears
Kindly, expect the unmatched and unparalleled physical therapy and rehab ... a solid treatment regimen addressing not just your symptoms, but your problems....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hi @mcollina I have put together this repo with all required details to reproduce the issue
NodeJS_Fastify_AutoCannon
All instructions are spelled out in readme file for above repo
Cheers !
Hi @mcollina
there is deeper problem wherein
resp.body
always is string so my below code will only work ifresp.body
follows actual api response type whether it is obj or stringfurther investigation points to below
const HTTPParser = require('http-parser-js').HTTPParser
which parses and it seems convert all responses to string again that is as per my investigation correct me if i am wrong