title: How to test Node redirection with Jest
body: <p>I am using Jest to test my Node REST API. </p>
  
  <p>The problem I have currently is that when I try testing my POST routes, I always receive a status code of 302 due to <code>res.redirect("/")</code>.</p>
  
  <p>Example of my POST route:</p>
  
  <pre><code>app.post("/login", async (req, res) =&gt; {
      try {
        let username = 'example'
  
        ...
        return res.redirect("/");
  
      } catch (error) {
         return res.redirect("/");
      }
    });
  </code></pre>
  
  <p>jest test file:</p>
  
  <pre><code>'use strict';
  const request = require('supertest');
  const app = require('./index');
  ...
  describe('Test', () =&gt; {
  
     test('POST /login', () =&gt; {
         return request(app)
               .post('/login')
               .set('username','example')
               .expect(?)
  
      });
  
  });
  </code></pre>
  
  <p>How can I test that the page has redirected successfully?</p>