Skip to content

Commit 343e12e

Browse files
authored
chore: fix more typos (#2)
1 parent b5430cb commit 343e12e

File tree

40 files changed

+114
-114
lines changed

40 files changed

+114
-114
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# Sunsetting JSDOM
22

3-
Great job! 🎉 Take some rest and let's continue.
3+
Great job! 🎉 Have some rest and let's continue.

exercises/02.vitest-browser-mode/04.problem.shared-assets/README.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ Once you do all this, you will spot that the `*.css` imports fail to resolve in
2626
Cannot find module './src/index.css' or its corresponding type declarations.ts(2307)
2727
```
2828

29-
🐨 To fix this, we need to pull some of the Vite built-in type definitions to help us. At the top of the `vitest.browser.setup.ts` file, add the following type reference comment:
29+
🐨 To fix this, we need to pull in some of the Vite built-in type definitions to help us. At the top of the `vitest.browser.setup.ts` file, add the following type reference comment:
3030

3131
```ts nonumber
3232
/// <reference path="./src/vite-env.d.ts" />
3333
```
3434

35-
Lastly, provide the path to the setup file in <InlineFile file="vite.config.ts">`vite.config.ts`</InlineFile> as the `setupFiles` value of a conrete browser instance (follow the instructions in the configuration file for more details).
35+
Lastly, provide the path to the setup file in <InlineFile file="vite.config.ts">`vite.config.ts`</InlineFile> as the `setupFiles` value of a concrete browser instance (follow the instructions in the configuration file for more details).
3636

3737
Once you have it ready, run the tests again to see the `<FilePreview />` component reclaim its striking visuals ✨.

exercises/02.vitest-browser-mode/04.solution.shared-assets/README.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ There are two types of test setup you can have: _global_ and _local_. The global
44

55
I will start by creating a `vitest.browser.setup.ts` file. The naming here doesn't matter that much, but I like to keep Vitest-related files starting with `vitest.*`.
66

7-
In that file, I will import the assets I want to apply to all rendered components:
7+
In that file, I will import the assets I want to include when rendering any component:
88

99
```ts filename=vitest.browser.setup.ts add=1
1010
import './src/index.css'

exercises/02.vitest-browser-mode/05.problem.multiple-workspaces/README.mdx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
# Multiple workspaces
22

3-
The way you have Vitest configured right now will run _all tests_ using the Browser Mode. This may be not what you want, especially if you are using Vitest for unit testing or integration testing in Node.js in the same project that needs in-browser component tests as well.
3+
Our current Vitest configuration runs _all tests_ in Browser Mode. This isn't ideal when you need to run different types of tests in the same project - like unit and integration tests running in a Node.js environment alongside browser-based component tests.
44

5-
You can fix this by introducing _different workspaces_ for differnt types of tests. In fact, I think this is just the right task for you...
5+
You can fix this by introducing _different workspaces_ for different types of tests. In fact, I think this is just the right task for you...
66

7-
👨‍💼 In this one, you will expand on the Vitest configuration to support running multiple types of tests in the same project. This will be a multi-step process to make sure you have the Vitest and TypeScript configured correctly for your tests.
7+
👨‍💼 In this one, you will expand the Vitest configuration to support running multiple types of tests in the same project. This will be a multi-step process to make sure you have Vitest and TypeScript configured correctly for your tests.
88

9-
🐨 First, update <InlineFile file="vite.config.ts">`vite.config.ts`</InlineFile> to list multiple [workspaces](https://main.vitest.dev/guide/workspace.html#configuration). Define one for unit tests and the other for component tests.
9+
🐨 First, update <InlineFile file="vite.config.ts">`vite.config.ts`</InlineFile> to list multiple [workspaces](https://main.vitest.dev/guide/workspace.html#configuration). Define one for unit tests and another for component tests.
1010

11-
🐨 Next, rename <InlineFile file="tsconfig.test.json">`tsconfig.test.json`</InlineFile> to `tsconfig.test.browser.json`. This TypeScript configuration will apply only to the component tests now. Update its `include` to target `**/*.browser.test.ts*` files:
11+
🐨 Next, rename <InlineFile file="tsconfig.test.json">`tsconfig.test.json`</InlineFile> to `tsconfig.test.browser.json`. This TypeScript configuration will only apply to the component tests now. Update its `include` setting to target `**/*.browser.test.ts*` files:
1212

1313
```json filename=tsconfig.test.browser.json remove=2 add=3
1414
{
@@ -17,7 +17,7 @@ You can fix this by introducing _different workspaces_ for differnt types of tes
1717
}
1818
```
1919

20-
🐨 To have proper type-checking in unit tests, create a new <InlineFile file="tsconfig.test.unit.json">`tsconfig.test.unit.json`</InlineFile> file and list there the properties necessary for the unit tests. You can use this as an example:
20+
🐨 To have proper type-checking in unit tests, create a new <InlineFile file="tsconfig.test.unit.json">`tsconfig.test.unit.json`</InlineFile> file and add the necessary properties for unit tests. You can use this as an example:
2121

2222
```json filename=tsconfig.test.unit.json
2323
{
@@ -49,6 +49,6 @@ You can fix this by introducing _different workspaces_ for differnt types of tes
4949
}
5050
```
5151

52-
🐨 Finally, rename the existing `file-preview.test.tsx` component test to `file-preview.browser.test.tsx` to be picked up by the proper workspace in Vitest.
52+
🐨 Finally, rename the existing `file-preview.test.tsx` component test to `file-preview.browser.test.tsx` to be included in the correct Vitest workspace.
5353

5454
See you on the other side once you're done to go through each step in more detail.

exercises/02.vitest-browser-mode/05.solution.multiple-workspaces/README.mdx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ The first workspace include the configuration for running unit tests:
7575
- `exclude` does the opposite of `include`, listing the file patterns to _ignore_. Since my browser tests also end with `*.test.ts`, I need to exclude them not to be confused with unit tests;
7676
- `environment` controls the test environment used for this workspace. I want my unit tests to run in Node.js, so I provide `'node'` as the enivornment here.
7777

78-
> :owl: Notice that each workspace lists Vitest configuration starting from the root (e.g. includes the `test` key again). This is handy because this means each workspace can have a different set of Vite options to handle the test files (e.g. list different `plugins`).
78+
> :owl: Notice that each workspace lists Vitest configuration starting from the root by including the `test` key again. This is handy because each workspace can have a different set of Vite options and `plugins` for different test files.
7979
8080
Similarly, here's the workspace for the browser (component) tests:
8181

@@ -99,17 +99,17 @@ Similarly, here's the workspace for the browser (component) tests:
9999
},
100100
```
101101

102-
Here, I'm naming this workspace `'browser'` and configuring it to include only `*.browser.test.ts(x)` test files. Those will be my component tests. For the rest of it, I simply moved the existing `test.browser` configuration under this workspace and left it as-is.
102+
Here, I'm naming this workspace `'browser'` and configuring it to include only `*.browser.test.ts(x)` test files. These will be my component tests. For the rest of the configuration, I simply moved the existing `test.browser` configuration under this workspace and left it as-is.
103103

104104
## TypeScript
105105

106-
The next step is to deal with TypeScript. One of the most overlooked aspects of using TypeScript is that you often need _multiple configurations_ within the same project. Your source code, unit tests, integration tests, or test utilities are all written in TypeScript but have different concerns that may require different types.
106+
The next step is to deal with TypeScript. One of the most overlooked aspects of using TypeScript is that you often need _multiple configurations_ within the same project. Your source code, unit tests, integration tests, and test utilities are all written in TypeScript but have different concerns that may require different types.
107107

108108
> :scroll: If you want to dive deeper into the reason behing using multiple TypeScript configurations and how to do that properly, read my post called [One Thing Nobody Explained To You About TypeScript](https://kettanaito.com/blog/one-thing-nobody-explained-to-you-about-typescript).
109109
110-
In our project, unit and component tests have a different set of type requirements because they run in different environments. This means I need to introduce two separate configurations: `tsconfig.test.unit.json` and `tsconfig.test.browser.json` to address those differences.
110+
In our project, unit and component tests have a different set of type requirements because they run in different environments. This means I need to introduce two separate configurations to address these differences: `tsconfig.test.unit.json` and `tsconfig.test.browser.json`.
111111

112-
Let's start with the unit tests.
112+
Let's start with the unit tests:
113113

114114
```json filename=tsconfig.test.unit.json
115115
{
@@ -130,7 +130,7 @@ Similar to how I've configured Vitest workspaces to apply only to specific file
130130
"types": ["node", "vitest/globals"]
131131
```
132132

133-
This include Node.js type definitions (`@types/node`) and Vitest global types (e.g. `test` and `expect`) for my unit tests. Since I don't have the Node.js types installed, I need to add them as a dependency to the project:
133+
This includes Node.js type definitions (`@types/node`) and Vitest global types (e.g. `test` and `expect`) for my unit tests. Since I don't have the Node.js types installed, I need to add them as a dependency to the project:
134134

135135
```sh nonumber
136136
npm i -D @types/node
@@ -152,7 +152,7 @@ Next, I rename the existing `tsconfig.test.json` to `tsconfig.test.browser.json`
152152

153153
## Test commands
154154

155-
To make it easier to run specific types of tests, I will modify `package.json` to include the new `test:unit` and `test:integration` commands:
155+
To make it easier to run specific types of tests, I will modify `package.json` to add `test:unit` and `test:integration` commands:
156156

157157
```json
158158
{
@@ -171,4 +171,4 @@ There are multiple ways to group different types of tests in the same project:
171171
- **By file name**. This is the one I'm using this exercise, adopting `*.test.ts` for unit tests and `*.browser.test.tsx` for integration tests;
172172
- **By directory name**. For example, you can keep unit tests in `./src` while integration tests in `./tests`
173173

174-
The only wrong choice here is the one not followed consistently. You can choose whichever approach makes more sense in your circumstance, but I don't recommend mixing them in the same app.
174+
The choice is up to you — I only recommend you stick to one approach and don't mix them in your app.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# Vitest Browser Mode
22

3-
Great job! 🎉 Take some rest and let's continue.
3+
Great job! 🎉 Have a rest and let's continue.
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# Queries
22

3-
One of the primary ways to achieve user-driven tests is to access and interact with the UI elements in the same manner user would. Your users don't know HTML or CSS so they don't locate elements on the page by their class names or `test-id` attributes. Instead, they find the things they need by their _roles_ and _names_ (this is true for visually-impared users as well).
3+
One of the primary ways to achieve user-driven tests is to access and interact with the UI elements in the same way the user would. Your users don't know HTML or CSS so they don't locate elements on the page by their class names or `test-id` attributes. Instead, they find the things they need by their _roles_ and _names_ (this is true for visually-impared users as well).
44

55
The way you access different elements in tests matters a lot. It can vary from giving you a ton of value and implicit accessibility assurance to forcing you to change your tests all the time because they are riddled with implementation details.
66

7-
<callout-info>When testing, do what users do.</callout-info>
7+
<callout-info>When testing, do what your users would do.</callout-info>
88

99
👨‍💼 In this exercise, your task is to write a simple integration test for a new React component called <InlineFile file="./src/discount-code-form.tsx">
10-
`<DiscountCodeForm />`</InlineFile>. And what do you know it—this component is a _form_! This means plenty of elements for you to locate. Use locators like `.getByRole()` and `.getByLabelText()`, and write assertions that make sure all the necessary form elements are present on the page.
10+
`<DiscountCodeForm />`</InlineFile>. And what do you know—this component is a _form_! This means plenty of elements for you to locate. Use locators like `.getByRole()` and `.getByLabelText()`, and write assertions that make sure all the necessary form elements are present on the page.

exercises/03.best-practices/01.solution.accessibility-selectors/README.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ I'm going to start by locating the discount code input on the page. This one:
1717
/>
1818
```
1919

20-
A user would find this input by its _label text_ because they would see that it says "Discount code" above that input. When creating the `<DiscountCode />` component, I've made sure to have an accessible layout by associating a `label` element with the input by its `id`:
20+
A user would find this input by its _label text_ because they would see that it says "Discount code" above that input. When creating the `<DiscountCode />` component, I've made sure to have accessible markup by associating a `label` element with the input by its `id`:
2121

2222
```tsx filename=discount-code-form.tsx highlight=2,8
2323
<label
@@ -120,7 +120,7 @@ But there are also elements that don't. Some derive their accessible name from t
120120
121121
And then there are elements that don't need accessible name at all. Those include `<section>`, `<p>`, `<span>`, or images that are purelly illustrational.
122122

123-
<callout-success>Select elements by their accessible name if it has one, otherwise select it by their text content. Do not add ARIA role attributes or accessible names where they are not needed! The goal is always accessible layout first, tests second. Never the other way around. See [Naming techniques](https://www.w3.org/WAI/ARIA/apg/practices/names-and-descriptions/#naming_techniques) for more details.</callout-success>
123+
<callout-success>Select elements by their accessible name if it has one, otherwise select it by their text content. Do not add ARIA role attributes or accessible names where they are not needed! The goal is always accessible markup first, tests second. Never the other way around. See [Naming techniques](https://www.w3.org/WAI/ARIA/apg/practices/names-and-descriptions/#naming_techniques) for more details.</callout-success>
124124

125125
### Text content
126126

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

3-
The way your test interacts with UI elements is just as important as the way it locates them. Naturally, your users don't dispatch events on elements or programmatically access them. They hover, click, type, drag. They do what their input devices allow them to do.
3+
How your tests interact with UI elements is just as important as how they locate them. Your users don't dispatch events or programmatically access elements — they hover, click, type, and drag using their input devices.
44

5-
So, how do you bring your tests to do the same? For a long while, integration testing revolved around _simulating_ user events. That was mostly due to the environmental limitations as you cannot really interact with a UI element in Node.js.
5+
So, how can we replicate real user interactions in our tests? Historically, integration testing relied on _simulating_ user events, mainly because Node.js can't actually interact with UI elements.
66

7-
**But your component tests aren't running in Node.js anymore**. Being in the real browser also means utlizing real user events. Actually hovering, clicking, typing, or dragging. One more benefit to reap from testing the code where it's supposed to run.
7+
**But your component tests aren't running in Node.js anymore**. Being in the real browser also means using real user events. Actually hovering, clicking, typing, or dragging. One more benefit to reap from testing the code where it's supposed to run.
88

9-
👨‍💼 This exercises has the following task for you in store: complete the automated test at <InlineFile file="./src/discount-code-form.browser.test.tsx">`discount-code-form.browser.test.tsx`</InlineFile> to enter a discount code, submit it, and assert that it has actually been applied (i.e. became visible as applied in the UI).
9+
👨‍💼 This exercise has the following task for you: complete the automated test at <InlineFile file="./src/discount-code-form.browser.test.tsx">`discount-code-form.browser.test.tsx`</InlineFile> to enter a discount code, submit it, and verify it appears correctly in the UI.
1010

11-
Give it your best and see you in the solution to this exercise!
11+
Give it your best shot and see you in the solution to this exercise!

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)