Skip to content

possible incorrect format of json bodies in response #35

@ghinks

Description

@ghinks

I believe that the update to supertest/superagent(depenency) from major version 2 to 3 has caused the body part of the supersamples report to change from being json formated to a single escaped string.

This is what is seen if you use supertest 3.0.0

screen shot 2017-02-23 at 9 20 52 pm

whereas if supertest 2.0.0 is used you see

screen shot 2017-02-23 at 9 23 13 pm

I have a simple repo to demonstrate the issue https://github.com/ghinks/supersamples-json-issue.git

I'm happy to lend a hand sorting it out too :)

node version 4.2.6

I'm probable not as familiar with this as you but the superagent response does not have body so I tried this hack

function extractResponse(superTest, response) {
    if (!superTest.res.body) {
        console.log('no body on the supertest response');
        console.log(`but the text was ${superTest.res.text}`);
    } else {
        console.log('was a body');
    }
    const headers = responseHeaders(superTest, response);
    console.log(`headers are ....=======> ${JSON.stringify(headers)}`);
    // headers.forEach(h => console.log(`${h}`));
  return {
    status: response.status,
    headers: headers,
    body: superTest.res.body || JSON.parse(superTest.res.text)
  };
}```

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions