question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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 ?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:3
  • Comments:11 (3 by maintainers)

github_iconTop GitHub Comments

5reactions
Christilutcommented, Mar 12, 2019

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

1reaction
akirilyukcommented, Mar 13, 2019

@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?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Migrate apps from Azure Functions version 3.x to 4.x
The easiest way is to upgrade without slots and then republish your app project. You can also minimize the downtime in your app...
Read more >
Migrating from 3.x to 4.0 - Socket.IO
Breaking changes. io.to() is now immutable; wsEngine option · Configuration. Ensure compatibility with Swift v15 clients; The default value of ...
Read more >
Migrating from 3.x to 4.x · expressjs/express Wiki - GitHub
This method is no longer available. If you wish to configure different routes based on environment, use either an if statement or another...
Read more >
Upgrading from 3.x to 4.x — CodeIgniter 4.2.11 documentation
There is no 12-step checklist for upgrading. Instead, start with a copy of CodeIgniter 4 in a new project folder, however you wish...
Read more >
Migrating from Spring Security 3.x to 4.x (XML Configuration)
This guide is intended to help users migrate from Spring Security 3.x to Spring Security 4.x when using XML based configuration.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found