Skip to content

Commit 23c1b6b

Browse files
committed
02/05: fix descriptions
1 parent d987a67 commit 23c1b6b

File tree

4 files changed

+24
-24
lines changed

4 files changed

+24
-24
lines changed

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,9 @@ You can fix this by introducing _different workspaces_ for different types of te
2222
```json filename=tsconfig.test.unit.json
2323
{
2424
"extends": "./tsconfig.base.json",
25-
"include": ["**/*.test.ts*"],
26-
"exclude": ["**/*.browser.test.ts*"],
25+
"include": ["src/**/*.test.ts*"],
26+
"exclude": ["src/**/*.browser.test.ts*"],
2727
"compilerOptions": {
28-
"target": "esnext",
29-
"module": "preserve",
3028
"types": ["node", "vitest/globals"]
3129
}
3230
}

exercises/02.vitest-browser-mode/05.problem.multiple-workspaces/vite.config.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/// <reference types="vitest" />
22
import { defineConfig } from 'vite'
3-
// 🐨 Import `defaultConfig` from `vitest/config`
3+
// 🐨 Import `configDefaults` from `vitest/config`
44
// 💰 import { foo } from 'bar'
55
import react from '@vitejs/plugin-react'
66
import tailwindcss from '@tailwindcss/vite'
@@ -9,7 +9,7 @@ export default defineConfig({
99
plugins: [react(), tailwindcss()],
1010
// 🐨 Add a new property called `workspace`.
1111
// As the value, provide an array with two entries.
12-
// 💰 workspace: [{}, {}]
12+
// 💰 test: { workspace: [{}, {}] }
1313
//
1414
// 🐨 In the first entry of the `workspace` array,
1515
// define a `test` property and give it a `test.name` equal to "unit".
@@ -31,18 +31,18 @@ export default defineConfig({
3131
// default values to ignore tests from `node_modules`, for example.
3232
// 💰 exclude: [...defaultConfig.exclude, '**/*.browser.test.ts(x)?']
3333
//
34-
// 🐨 Now, switch to the second entry in the `workspace`
35-
// array. There, give it the following properties:
34+
// Now, switch to the second entry in the `workspace` array.
35+
// 🐨 First, set the `extends` property to `true`. Let's extend the
36+
// root-level options, like `plugins` to have consistent behavior in prod and tests.
37+
// 💰 { extends: true, test: {} }
38+
//
39+
// 🐨 Next, add these properties to the `test` in this workspace:
3640
// {
3741
// name: "browser",
3842
// globals: true,
3943
// include: ["**/*.browser.test.ts(x)?"]
4044
// }
4145
//
42-
// 🐨 At the root-level of the browser workspace object
43-
// set the `extends` property to true. This will use the
44-
// root-level plugins, like `react()`, for browser tests.
45-
//
4646
// 🐨 Finally, copy the existing `browser` configuration
4747
// under the `test` property of the second workspace.
4848
// 💰 { test: { name: 'browser', browser: {...} }}

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

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ export default defineConfig({
2727
test: {
2828
name: 'unit',
2929
globals: true,
30+
environment: 'node',
3031
include: ['**/*.test.ts'],
3132
exclude: [...configDefaults.exclude, '**/*.browser.test.ts(x)?'],
32-
environment: 'node',
3333
},
3434
},
3535
{
@@ -64,9 +64,9 @@ The first workspace include the configuration for running unit tests:
6464
test: {
6565
name: 'unit',
6666
globals: true,
67+
environment: 'node',
6768
include: ['**/*.test.ts'],
6869
exclude: ['**/*.browser.test.ts(x)?'],
69-
environment: 'node',
7070
},
7171
},
7272
```
@@ -82,6 +82,7 @@ Similarly, here's the workspace for the browser (component) tests:
8282

8383
```ts filename=vite.config.ts nonumber
8484
{
85+
extends: true,
8586
test: {
8687
name: 'browser',
8788
globals: true,
@@ -115,11 +116,9 @@ Let's start with the unit tests:
115116
```json filename=tsconfig.test.unit.json
116117
{
117118
"extends": "./tsconfig.base.json",
118-
"include": ["**/*.test.ts*"],
119-
"exclude": ["**/*.browser.test.ts*"],
119+
"include": ["src/**/*.test.ts*"],
120+
"exclude": ["src/**/*.browser.test.ts*"],
120121
"compilerOptions": {
121-
"target": "esnext",
122-
"module": "preserve",
123122
"types": ["node", "vitest/globals"]
124123
}
125124
}
@@ -139,13 +138,16 @@ npm i -D @types/node
139138

140139
Next, I rename the existing `tsconfig.test.json` to `tsconfig.test.browser.json` to act as the TypeScript configuration for my browser component tests:
141140

142-
```json highlight=3,7
141+
```json highlight=6,10
143142
{
144-
"extends": "./tsconfig.base.json",
145-
"include": ["vitest.browser.setup.ts", "**/*.browser.test.ts*"],
143+
"extends": "./tsconfig.app.json",
144+
"include": [
145+
"vitest.browser.setup.ts",
146+
"src/**/*",
147+
"src/**/*.browser.test.ts*"
148+
],
149+
"exclude": [],
146150
"compilerOptions": {
147-
"target": "esnext",
148-
"module": "preserve",
149151
"types": ["vitest/globals", "@vitest/browser/providers/playwright"]
150152
}
151153
}

exercises/02.vitest-browser-mode/05.solution.multiple-workspaces/vite.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ export default defineConfig({
1212
test: {
1313
name: 'unit',
1414
globals: true,
15+
environment: 'node',
1516
include: ['**/*.test.ts'],
1617
exclude: [...configDefaults.exclude, '**/*.browser.test.ts(x)?'],
17-
environment: 'node',
1818
},
1919
},
2020
{

0 commit comments

Comments
 (0)