Skip to content

Commit 28aa0ca

Browse files
committed
grammar and flow
1 parent 9c39365 commit 28aa0ca

File tree

1 file changed

+8
-8
lines changed
  • exercises/02.vitest-browser-mode/05.solution.multiple-workspaces

1 file changed

+8
-8
lines changed

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
@@ -74,7 +74,7 @@ The first workspace include the configuration for running unit tests:
7474
- `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;
7575
- `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.
7676

77-
> :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`).
77+
> :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.
7878
7979
Similarly, here's the workspace for the browser (component) tests:
8080

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

101-
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.
101+
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.
102102

103103
## TypeScript
104104

105-
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.
105+
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.
106106

107107
> :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).
108108
109-
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.
109+
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`.
110110

111-
Let's start with the unit tests.
111+
Let's start with the unit tests:
112112

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

132-
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:
132+
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:
133133

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

152152
## Test commands
153153

154-
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:
154+
To make it easier to run specific types of tests, I will modify `package.json` to add `test:unit` and `test:integration` commands:
155155

156156
```json
157157
{
@@ -170,4 +170,4 @@ There are multiple ways to group different types of tests in the same project:
170170
- **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;
171171
- **By directory name**. For example, you can keep unit tests in `./src` while integration tests in `./tests`
172172

173-
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.
173+
The choice is up to you — I only recommend you stick to one approach and don't mix them in your app.

0 commit comments

Comments
 (0)