I'm using supertest to implement a batch of canary tests for a quirky Web API that I don't control. One of the API's quirks consists of returning a plaintext string in a response that declares the Content-Type
to be application/json
.
This particular combination of factors leads supertest to throw the following error:
SyntaxError: Unexpected token s in JSON at position 0
at JSON.parse (<anonymous>)
at Stream.res.on (node_modules/superagent/lib/node/parsers/json.js:11:35)
at Unzip.unzip.on (node_modules/superagent/lib/node/unzip.js:55:12)
at endReadableNT (_stream_readable.js:1064:12)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
at process._tickCallback (internal/process/next_tick.js:180:9)
Does anyone know if there is any way to disable parsing the response body?