lundi 27 février 2017

Supertest not working with routes that call .render()

Supertest does not work with any route in my app that calls res.render(). The test just times out, it doesn't execute the end or expect callbacks.

Static routes and routes that just call res.send work as expected.

In the browser my app works perfectly for all routes.

I started listening to the res.render callback to make sure there wasn't a rendering error, and the callback is called just fine during tests with the correct rendered template.

What can be causing the test to timeout?

Here is an example route I set, which doesn't work.

 app.get("/test", (req, res) => res.render("dashboard"));

And here is my spec:

it("at least returns something", (done) => {
            request(app)
                .get("/test")
                .expect(200)
                .end(err =>
                  err
                    ? done.fail(err)
                    : done()
                );
        });

Aucun commentaire:

Enregistrer un commentaire