@@ -7,11 +7,11 @@ test development by automatically mocking class external dependencies.
7
7
#### Introduction
8
8
9
9
The dependency injection (DI) container is an essential component of the Nest module system.
10
- This container is utilized both during testing, and the application execution. \
10
+ This container is utilized both during testing, and the application execution.
11
11
Unit tests vary from other types of tests, such as integration tests, in that they must
12
12
fully override providers/services within the DI container. External class dependencies
13
13
(providers) of the so-called "unit", have to be totally isolated. That is, all dependencies
14
- within the DI container should be replaced by mock objects. \
14
+ within the DI container should be replaced by mock objects.
15
15
As a result, loading the target module and replacing the providers inside it is a process
16
16
that loops back on itself. Automock tackles this issue by automatically mocking all the
17
17
class external providers, resulting in total isolation of the unit under test.
@@ -28,7 +28,9 @@ Automock does not require any additional setup.
28
28
Sinon will shortly be released.
29
29
30
30
#### Example
31
+
31
32
Consider the following cats service, which takes three constructor parameters:
33
+
32
34
``` ts
33
35
@@filename (cats .service )
34
36
import { Injectable } from ' @nestjs/core' ;
@@ -92,6 +94,7 @@ describe('Cats Service Unit Spec', () => {
92
94
> wrapped with type definitions of Jest mock function. ([ reference] ( https://jestjs.io/docs/mock-function-api/#jestmockedsource ) )
93
95
94
96
#### About ` unit ` and ` unitRef `
97
+
95
98
Let's examine the following code:
96
99
97
100
``` typescript
0 commit comments