I'm writing unit tests for an API.
If I do something like this :
const apiResponse:object = JSON.parse(body)
expect(apiResponse).toHaveProperty('error')
and the API is not returning JSON, then I get something like :
SyntaxError: Unexpected token p in JSON at position 0 at JSON.parse ()
Rather than getting an error in my tests, I'd like my test to fail.
What is a jest test I can do that says;
is this string I've received parsable as valid JSON?