Skip to content

Commit 2edabda

Browse files
committed
grammar
1 parent e1bb4b1 commit 2edabda

File tree

1 file changed

+6
-6
lines changed
  • exercises/03.best-practices/02.solution.user-events

1 file changed

+6
-6
lines changed

exercises/03.best-practices/02.solution.user-events/README.mdx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# User events
22

3-
At its current state, our discount form component test gives you some value, but it can give much more. We don't create UI elements simply for them "to be" on the page. They are there so our users could interact with them, make them do something, help them achieve their tasks.
3+
In its current state, our discount form component test gives you some value, but it can give so much more. We don't create UI elements simply for them "to be" on the page. They are there so our users can interact with them, make them do something, and help them achieve their tasks.
44

55
The main purpose of the discount form component is to apply the given discount code. _That_ is what has to be reflected in automated tests.
66

@@ -21,7 +21,7 @@ test('applies a discount code', async () => {
2121
await expect.element(discountInput).toBeVisible()
2222
```
2323
24-
I intend to _interact_ with the `discountInput` element so asserting its visibility on the page becomes redundant. Its interactivity is _implied_ by the interaction. If this input is, say, not being rendered correctly, interacting with it will fail. This is called an _implicit assertion_.
24+
I intend to _interact_ with the `discountInput` element so asserting its visibility on the page is redundant. Its interactivity is _implied_ by the interaction. If this input is, say, not being rendered correctly, interacting with it will fail. This is called an _implicit assertion_.
2525
2626
> 🦉 [Implicit assertions](https://www.epicweb.dev/implicit-assertions) are a great way to achieve more in tests while writing less.
2727
@@ -35,11 +35,11 @@ test('applies a discount code', async () => {
3535
await discountInput.fill('EPIC2025')
3636
```
3737
38-
The `.fill()` method accepts a _value_ to enter and returns a promise that resolves when the browser is done typing it in.
38+
The `.fill()` method accepts a _value_ to enter and returns a promise that resolves when the browser is finished typing it in.
3939
4040
Now that the discount code has been entered, it's time to apply it.
4141
42-
Much the same, I will drop the redundant visibility assertiom from the `applyDiscountCode` button, and replace it with the `.click()` interaction with that button:
42+
As above, I will drop the redundant visibility assertion from the `applyDiscountCode` button, and replace it with the `.click()` interaction with that button:
4343
4444
```tsx filename=discount-code-form.browser.test.tsx remove=10 add=11 nocopy
4545
test('applies a discount code', async () => {
@@ -70,7 +70,7 @@ My expectation here is derived from _how_ the applied discount code is displayed
7070
)
7171
```
7272
73-
So, in case the code has been successfully applied, I expect this paragraph to be visible on the page:
73+
Finally, when the code has been successfully applied, I expect this paragraph to be visible on the page:
7474
7575
```tsx filename=discount-code-form.browser.test.tsx add=13-15 nocopy
7676
test('applies a discount code', async () => {
@@ -95,7 +95,7 @@ This completes the test! 🎉
9595
9696
## Locator methods vs `userEvent`
9797
98-
If you used React Testing Library in the past, you've likely been interacting with your components via the `userEvent` object from `@testing-library/user-event`. Vitest provides you a similar object from the `@vitest/browser/context` package as well:
98+
If you used React Testing Library in the past, you've likely been interacting with your components via the `userEvent` object from `@testing-library/user-event`. Vitest provides you a similar object from the `@vitest/browser/context` package:
9999
100100
```tsx nonumber highlight=1,7
101101
import { userEvent } from '@vitest/browser/context',

0 commit comments

Comments
 (0)