I need to insert a check to compare response bodies. If I declare it like this:
check(bodyString.is(expectedResponseBody))
then I get the following error:
bodyString.find.is({"jsonrpc":"2.0","id":123456,"result":{"message":"OK"}}), but actually found {"jsonrpc":"2.0","id":123456,"result":{"message":"OK"}}
I suppose the problem is different types, because the byte values are different. Should I use transform? If so, how should I do this? Thanks for your attention.
Weird.
Are you sure you don’t have a different character somewhere, such as Linux vs Windows line feeds and such?
Could you please provide a reproducer?
I tried different options and what did the trick is:
`
check(bodyString.transform(string => string.trim).is(expectedResponseBody))
`
Can it be the case, that leading and trailing are not being logged?
Could you compare the lengths?
Or provide a reproducer?
I unfortunately cannot provide a reproducer. The response is coming from our internal server. I tried to compare lengths though and got the following results:
`
09:15:20.826 - Expected response is: {“jsonrpc”:“2.0”,“id”:123456,“result”:{“message”:“OK”}}: Length: 55
09:15:20.826 - BodyString response is: {“jsonrpc”:“2.0”,“id”:123456,“result”:{“message”:“OK”}}
: Length: 56
`
So there was apparently a ‘\n’ character in the end, but it didn’t display in the 'bodyString.find.is(…) block.
In your original message, you copied:
bodyString.find.is({"jsonrpc":"2.0","id":123456,"result":{"message":"OK"}}), but actually found {"jsonrpc":"2.0","id":123456,"result":{"message":"OK"}}
Are you sure you didn’t get an additional line feed after this line?
Yes, you are right. The whole message is:
`
09:55:46.184 [TRACE] i.g.h.a.ResponseProcessor -
Request:
deleteAccount: should succeed: KO bodyString.find.transform.is({“jsonrpc”:“2.0”,“id”:123456,“result”:{“message”:“OK”}}), but actually found {“jsonrpc”:“2.0”,“id”:123456,“result”:{“message”:“OK”}}