Skip to content

Commit e094cb7

Browse files
authored
Merge pull request #3950 from sudo-rickroll/patch-7
Update part4b.md
2 parents 49c75e6 + 66a86cd commit e094cb7

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/content/4/en/part4b.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ The problem here, however, is that when using a string, the value of the header
156156

157157
The test contains some details that we will explore [a bit later on](/en/part4/testing_the_backend#async-await). The arrow function that defines the test is preceded by the <i>async</i> keyword and the method call for the <i>api</i> object is preceded by the <i>await</i> keyword. We will write a few tests and then take a closer look at this async/await magic. Do not concern yourself with them for now, just be assured that the example tests work correctly. The async/await syntax is related to the fact that making a request to the API is an <i>asynchronous</i> operation. The async/await syntax can be used for writing asynchronous code with the appearance of synchronous code.
158158

159-
Once all the tests (there is currently only one) have finished running we have to close the database connection used by Mongoose. This can be easily achieved with the [after](https://nodejs.org/api/test.html#afterfn-options) method:
159+
Once all the tests (there is currently only one) have finished running we have to close the database connection used by Mongoose. Without this, the test program will not terminate. This can be easily achieved with the [after](https://nodejs.org/api/test.html#afterfn-options) method:
160160

161161
```js
162162
after(async () => {
@@ -192,7 +192,7 @@ The documentation for supertest says the following:
192192

193193
> <i>if the server is not already listening for connections then it is bound to an ephemeral port for you so there is no need to keep track of ports.</i>
194194
195-
In other words, supertest takes care that the application being tested is started at the port that it uses internally.
195+
In other words, supertest takes care that the application being tested is started at the port that it uses internally. This is one of the reasons why we are going with supertest instead of something like axios, as we do not need to run another instance of the server separately before beginning to test. The other reason is that supertest provides functions like <code>expect()</code>, which makes testing easier.
196196

197197
Let's add two notes to the test database using the _mongo.js_ program (here we must remember to switch to the correct database url).
198198

0 commit comments

Comments
 (0)