Skip to content

Commit d33d687

Browse files
committed
5c
1 parent 15740fe commit d33d687

File tree

2 files changed

+134
-64
lines changed

2 files changed

+134
-64
lines changed

src/content/5/en/part5c.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ afterEach(() => {
5757
})
5858
```
5959

60-
Now, after each test, the function _cleanup_ is performed that resets the jsdom that is simulating the browser.
60+
Now, after each test, the function _cleanup_ is executed to reset jsdom, which is simulating the browser.
6161

6262
Expand the _vite.config.js_ file as follows
6363

@@ -131,7 +131,7 @@ We can use the object [screen](https://testing-library.com/docs/queries/about#sc
131131
expect(element).toBeDefined()
132132
```
133133

134-
The existence of an element is checked using Vitest's [expect](https://vitest.dev/api/expect.html#expect) command. Expect generates an assertion from its parameter, the validity of which can be tested using various condition functions. Now we used [toBeDefined](https://vitest.dev/api/expect.html#tobedefined) which tests whether the _element_ parameter of expect exists.
134+
The existence of an element is checked using Vitest's [expect](https://vitest.dev/api/expect.html#expect) command. Expect generates an assertion for its argument, the validity of which can be tested using various condition functions. Now we used [toBeDefined](https://vitest.dev/api/expect.html#tobedefined) which tests whether the _element_ argument of expect exists.
135135

136136
Run the test with command _npm test_:
137137

@@ -384,7 +384,7 @@ The expectation of the test uses [toHaveLength](https://vitest.dev/api/expect.ht
384384
expect(mockHandler.mock.calls).toHaveLength(1)
385385
```
386386

387-
The calls of the mock function are saved to the array [mock.calls](https://vitest.dev/api/mock#mock-calls) within the mock function object.
387+
The calls to the mock function are saved to the array [mock.calls](https://vitest.dev/api/mock#mock-calls) within the mock function object.
388388

389389
[Mock objects and functions](https://en.wikipedia.org/wiki/Mock_object) are commonly used [stub](https://en.wikipedia.org/wiki/Method_stub) components in testing that are used for replacing dependencies of the components being tested. Mocks make it possible to return hardcoded responses, and to verify the number of times the mock functions are called and with what parameters.
390390

@@ -417,7 +417,6 @@ const Togglable = forwardRef((props, ref) => {
417417
The tests are shown below:
418418

419419
```js
420-
421420
import { render, screen } from '@testing-library/react'
422421
import userEvent from '@testing-library/user-event'
423422
import Togglable from './Togglable'
@@ -592,7 +591,7 @@ test('<NoteForm /> updates parent state and calls onSubmit', async() => {
592591
})
593592
```
594593

595-
In the middle of running the tests, the following is printed
594+
In the middle of running the tests, the following is printed in the console:
596595

597596
```
598597
[ [ { content: 'testing a form...', important: true } ] ]

0 commit comments

Comments
 (0)