Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

From 3.x to 4.x, is there a new way to use request() ? #557

Closed
converge opened this issue Mar 11, 2019 · 11 comments
Closed

From 3.x to 4.x, is there a new way to use request() ? #557

converge opened this issue Mar 11, 2019 · 11 comments
Assignees

Comments

@converge
Copy link

converge commented Mar 11, 2019

if I call my API in this way using Supertest 4.x:

return res.status(401).send()

and try to assert it in this way:

response = await request(app).post('/admin').send( { data_here } )
expect(response.status).toBe(401);

Supertest returns Unauthorized and not status code 401 as I'm expecting.

If I do the same thing using Supertest 3.x , it returns the status code I'm expecting to test it.

Is there a new way to do it on version 4.x ?

@sonicoder86
Copy link

We used to set the expected status code, like 401, but that no longer returns the response, it throws the error instead.
Seems like a breaking change without documentation.

@Christilut
Copy link

Same here, used this in 3.x:

  await request(app)
    .post('/system/invoice/generate')
    .set('content-type', 'application/json')
    .set('Authorization', 'invalidtoken')
    .send()
    .expect(httpStatus.UNAUTHORIZED)

Short migration guide would be nice

@bajtos
Copy link
Contributor

bajtos commented Mar 12, 2019

This may be a regression - see ladjs/superagent#1466

@bonesoul
Copy link

same and has been reported yesterday but still no fixes.

@akirilyuk
Copy link

Don't you have any tests which cover these cases? I mean there was already something similar:

#534

@SMenigat
Copy link

Don't you have any tests which cover these cases? I mean there was already something similar:

#534

Feel free to open an PR and add those tests 👍

@gjohnson
Copy link
Contributor

I’ve started adding a few tests, the problem is all the tests use callbacks only, so the regression was overlooked, again (sorry!).

@SMenigat
Copy link

Just to be clear, my comment was in @akirilyuk s direction.

@akirilyuk
Copy link

@SMenigat should not the person who created the fix also add the tests which verifies the error wont happen again? Also should it not be the maintainers job to have meaningful tests for their own product?

@bonesoul
Copy link

+1 with @akirilyuk

@rimiti
Copy link
Contributor

rimiti commented Mar 15, 2019

#558 merged, I close this issue.

Thank you 🙏

@rimiti rimiti closed this as completed Mar 15, 2019
mrtnzlml pushed a commit to kiwicom/fetch that referenced this issue Mar 15, 2019
This was blocked because of the following issue in Supertest but now it seems to be OK: ladjs/supertest#557

No issues expected.
mrtnzlml pushed a commit to kiwicom/relay that referenced this issue Mar 15, 2019
This was blocked because of the following issue in Supertest but now it seems to be OK: ladjs/supertest#557

No issues expected.
mrtnzlml pushed a commit to kiwicom/monorepo-utils that referenced this issue Mar 22, 2019
This was blocked because of the following issue in Supertest but now it seems to be OK: ladjs/supertest#557

No issues expected.
mrtnzlml pushed a commit to kiwicom/fetch that referenced this issue Apr 3, 2019
This was blocked because of the following issue in Supertest but now it seems to be OK: ladjs/supertest#557

No issues expected.

kiwicom-source-id: 02a0ff1ddb5ac6db2b24437efa759b0dbce4051a
mrtnzlml pushed a commit to kiwicom/monorepo-utils that referenced this issue Apr 3, 2019
This was blocked because of the following issue in Supertest but now it seems to be OK: ladjs/supertest#557

No issues expected.

kiwicom-source-id: 02a0ff1ddb5ac6db2b24437efa759b0dbce4051a
mrtnzlml pushed a commit to kiwicom/relay that referenced this issue Apr 3, 2019
This was blocked because of the following issue in Supertest but now it seems to be OK: ladjs/supertest#557

No issues expected.

kiwicom-source-id: 02a0ff1ddb5ac6db2b24437efa759b0dbce4051a
adeira-github-bot pushed a commit to kiwicom/graphql-global-id that referenced this issue Apr 8, 2019
This was blocked because of the following issue in Supertest but now it seems to be OK: ladjs/supertest#557

No issues expected.

kiwicom-source-id: 02a0ff1ddb5ac6db2b24437efa759b0dbce4051a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants