NodeJS, EJS and Jest.
The JS line calling render:
return res.status(200).render(‘users’, {data:allUsers});
The Jest test snippet:
await request(server) .get(“/users”) .send() .expect(200)
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);
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!
Hello,
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.
Best,
Bobby
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.