From the course: Node.js: Testing and Code Quality

Unlock the full course today

Join today to access over 24,400 courses taught by industry experts.

Solution: Organize your tests

Solution: Organize your tests

(upbeat music) - [Instructor] Here's the solution to the challenge about organizing your tests. If you haven't completed it yet, please take a moment to practice your skills. We'll start with unit tests which test the smallest piece of code. Unit tests are contained within the project itself. One common location for unit tests is the directory with the file being tested. So, file.test.js is the closest match. Integration tests combine multiple units and don't involve outside surfaces so within the project is the most logical location. Often, integration tests are against a particular API routes that may call multiple units in order to do their work. So, a route file within a tests subdirectory would be a good location. What about functional tests? These can sometimes involve a service like a database and larger pieces of the application. So, both within and outside the project are possible. Functional tests often have a…

Contents