Which tools/frameworks do you use to create automatic tests in Node.js?When you create a test case, is it supposed to be self-contained?

Hi, all. I have two questions and I would like to have your take on the topics.
  1. Which tools/frameworks do you use to create automatic tests in Node.js
  2. When you create a test case, is it supposed to be self-contained e.g. you have to test the correct creation of a Project object in MongoDB, but you need first an object of type User to do it, because a User creates a Project. In the test case, do you create a new User, and, then, a new Project to test the Project, or you assume that a User object already exists in the DB from a previous test case

You already invited:

trassmann

Upvotes from:

1. jest is the de facto standard and its a very nice API 
2. That kind of depends on what you want to cover with your test, but usually, integration testing is preferred, so you build real life scenarios, for example, if you have an express app then spinning up your actually app and sending requests to it and validating the response will guarantee that your app as a whole delivers consistent output based on input
but often you will write unit tests for helper functions that contain critical logic

If you wanna answer this question please Login or Register