Supertest: Tests with error return fail with version 3.4.0

Created on 16 Jan 2019  路  11Comments  路  Source: visionmedia/supertest

When using version 3.4.0 tests that test for backend returning an error (400) fail. Example:

it("Check that backend returns 400 with invalid data", async function() {
    let res = await server
        .post("/api/someurl")
        .send({data: "something invalid"})
        .expect("Content-type", /json/)
        .expect(400);
  });

When using version 3.4.0 this test fails with "Bad request" error even when backend returns correctly 400 status code.

With supertest 3.3.0 code works as expected.

bug needs-investigation

Most helpful comment

Hi, I am also experiencing the same issue!

All 11 comments

Hello @ilkkaparssinen,

Thank you for your feedback, we're investigating this issue.

Hi there,

I am experiencing a similar issue with the update.

Here is a gist of the error output: https://gist.github.com/4cm4k1/f1e9bd3d88c3ce1d069de8554a5b411b

Here are the tests being run: https://github.com/4cm4k1/domain-redirects/blob/master/test/index.js

I hope this helps!
Anthony

Thank you @4cm4k1 !

Hi, I am also experiencing the same issue!

Here's another build failure that may help, https://circleci.com/gh/Financial-Times/tako/175.

Hi,

I have the same issue.
As far as I checked, the problem probably with superagent version upgrade. It had a major version change.
The error thrown from node_modules/superagent/lib/node/index.js:804:15) because the _isResponseOK function only accept status codes as valid between 200 and 300 (node_modules/superagent/lib/request-base.js in row 275).

But I am not familiar with that area.

@gergaczd You right, this issue is related with superagent.
I'll temporarily downgrade it to hotfix the package.

After that, we'll make a hard refactoring because, all tests are OK. It's not normal.

A pull request has been created to hotfix that: #535 馃殌
Any feedback is welcome !

same here

Hotfix #535 fixes my problems (tested by changing my package.json to branch v3.4.1):
"supertest": "https://github.com/visionmedia/supertest.git#v3.4.1"

Thanks @ilkkaparssinen.

The hotfix #535 has been published.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mayacr86 picture mayacr86  路  4Comments

DeaconDesperado picture DeaconDesperado  路  6Comments

lovelydreamer picture lovelydreamer  路  4Comments

rkmax picture rkmax  路  5Comments

peterjuras picture peterjuras  路  3Comments