You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: testing/unit-testing-jest/docs/introduction.md
+9-7Lines changed: 9 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -15,18 +15,20 @@ Testing is a method to check if the code is working as expected. Testing the cod
15
15
16
16
### Principles
17
17
18
-
**Easy to write:** It should be easy to code all of those test routines without enormous effort.
18
+
**Easy to write:**it should be easy to code all of those test routines without enormous effort.
19
19
20
-
**Readable:**The intent of a unit test should be clear. A good unit test tells a story about some behavioral aspect of our application, so it should be easy to understand which scenario is being tested and — if the test fails — easy to detect how to address the problem.
20
+
**Readable:**the intent of a unit test should be clear. A good unit test tells a story about some behavioral aspect of our application, so it should be easy to understand which scenario is being tested and — if the test fails — easy to detect how to address the problem.
21
21
22
-
**Reliable:**Unit tests should fail only if there’s a bug in the system under test. Good unit tests should be reproducible and independent from external factors such as the environment or running order.
22
+
**Reliable:**unit tests should fail only if there’s a bug in the system under test. Good unit tests should be reproducible and independent from external factors such as the environment or running order.
23
23
24
-
**Fast:** Developers write unit tests so they can repeatedly run them and check that no bugs have been introduced. Slow unit tests may also indicate that either the system under test, or the test itself, interacts with external systems, making it environment-dependent.
24
+
**Fast:** developers write unit tests so they can repeatedly run them and check that no bugs have been introduced. Slow unit tests may also indicate that either the system under test, or the test itself, interacts with external systems, making it environment-dependent.
25
+
26
+
> Unit tests do NOT test the interaction with external modules. Everything related to real dependencies is tested in an **integration tests**.
25
27
26
28
### Unit test structure (AAA pattern)
27
-
- Arrange: Initializes the objects and establishes the values of the data that we are going to use in the Test that contains it.
28
-
- Act: Makes the call to the method to be tested with the parameters prepared for this purpose.
29
-
- Assert: Checks that the executed test method behaves as we expected it to.
29
+
- Arrange: initializes the objects and establishes the values of the data that we are going to use in the Test that contains it.
30
+
- Act: makes the call to the method to be tested with the parameters prepared for this purpose.
31
+
- Assert: checks that the executed test method behaves as we expected it to.
30
32
31
33
````ts
32
34
🏷️ describe('Class, Module, Service or Component to test', () => {
0 commit comments