Unit testing
As the name implies, each unit test cover one specific functionality. The most important principles when dealing with unit tests are:
- isolation; each component has to be tested without any other related components; it cannot be affected by side effects and, likewise, it cannot emit any side effects.
- predictability; each test has to yield the same results as long as the input doesn’t change.
In many cases, complying with these two principles means mocking (i.e. simulating the functionality of) the component dependencies.
Tooling
Unlike Angular, Nest.js doesn’t have an “official” toolset for running tests; this means we are free to set up our own tooling for running automated tests when we work in Nest.js projects.
There are multiple tools in the JavaScript ecosystem focused on writing and running automated unit tests. The typical solutions involve using several different packages for one setup, because those packages used to be limited in their...