NodeJS + EJS + Jest

  1. NodeJS, EJS and Jest.

  2. The JS line calling render:

    return res.status(200).render(‘users’, {data:allUsers});

  3. The Jest test snippet:

    await request(server) .get(“/users”) .send() .expect(200)

  4. The Jest error:

    GET /users GET /users › Return 200 with the list of users (99 ms)

    expected 200 “OK”, got 500 “Internal Server Error” 47 | .get(“/users”) 48 | .send()

    49 | .expect(200) | ^

To be able to pass the test:

return res.status(200).json(allUsers);

Submit an answer
Answer a question...

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Bobby Iliev
Site Moderator
Site Moderator badge
February 13, 2022


What I would suggest is to actually start testing why you are seeing the 500 internal server error as the test is expecting a status 200 OK.

Once you have the actual error rather than just the generic 500 error, feel free to share it here so I could try to advise you further.