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.

How does superdeno intercept redirects?

See original GitHub issue

Is there a way to test for redirects?

When I do something along the lines of:

    await superdeno(testApiUrl)
    .post('/api/to/endpoint/that/triggers/a/redirect')
    .expect((response, error) => {
       assertEquals(response.status, 302);
        assertEquals(response.headers.includes('location: http://google.com/'), true);
    });

This errors out and insists that the final state is 200, not 302.

I’ve noticed that the response.headers capture those of the final destination page rather than the actual API redirect state. Is there a way to go one step before the final destination URL?

I have also tried

    await superdeno(testApiUrl)
    .post('/api/to/endpoint/that/triggers/a/redirect')
    .expect(302)
    .expect((response, error) => {
        assertEquals(response.headers.includes('location: http://google.com/'), true);
    });

but to no effect.

Thanks heaps (again great library).

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
avihavaicommented, Dec 14, 2020

Awesome, this works brilliantly. Thanks a lot for the effort!

1reaction
cmortencommented, Dec 12, 2020

@avihavai, @viztastic support for a .redirects(n) API (as per superagent and supertest) has been released in 3.0.0.

I hope this helps with any missing test coverage you might have! Please raise new issues if you have any problems with it 🙃

Read more comments on GitHub >

github_iconTop Results From Across the Web

/test/redirects.test.ts | superdeno@4.2.1 | Deno
import * as superdeno from "https://deno.land/x/superdeno@4.2.1/test/redirects.test.ts";. The documentation for this module is currently unavailable.
Read more >
Deno nuggets: Redirect a request - Medium
The redirect function is a static function that takes an absolute URL, along with an optional status code. A Response object is returned....
Read more >
How to Intercept express redirect request - Stack Overflow
I have a use case where I want to redirect the client requests to https://ifconfig.co/json to get some info, but before I send...
Read more >
DNS port intercept redirect to multiple internal DNS servers
I am using the following firewall rules to intercept all DNS queries and redirect to my local pi-hole ( 10.1.1.2 ) server.
Read more >
Node.js Tips — Testing Redirects, Sessions, and Auth ...
To test requests that redirect to another route with Supertest running in ... We can add a middleware to a route to check...
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