4

If I have the following route:

app.post('/', (req, res, next) => {
  req.flash('errors', 'error');
  return res.redirect('/');
});

And the following supertest test:

describe('POST /', () => {
  it('should return a flash error', (done) => {
    request(app)
      .post('/')
      .expect('Location', '/')
      .expect(302)
      .end((err, res) => {
          console.log(res);
      });
    });
});

How can I verify the flash value? I logged the response and I can't find where they are stored. I found online that it might be in the body or text, but they are both empty. Is there another way? If it can help, I'm using this boilerplate with most things as it is.

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
Raphael Valois
  • 165
  • 3
  • 13

1 Answers1

0

Not sure if the question is still active, but try to use request.redirect. There are some examples in the express-flash repository: https://github.com/RGBboy/express-flash/blob/master/test/flash.spec.js

antklim
  • 381
  • 3
  • 7