Skip to content

Commit ffe04fa

Browse files
committed
02/04: add solution, proper ts configs
1 parent 34e0710 commit ffe04fa

38 files changed

+447
-110
lines changed
Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,9 @@
11
{
2+
"extends": "./tsconfig.base.json",
23
"compilerOptions": {
34
"target": "ES2020",
4-
"useDefineForClassFields": true,
5-
"lib": ["ES2020", "DOM", "DOM.Iterable"],
6-
"module": "ESNext",
7-
"skipLibCheck": true,
8-
9-
/* Bundler mode */
10-
"moduleResolution": "bundler",
11-
"allowImportingTsExtensions": true,
12-
"isolatedModules": true,
13-
"moduleDetection": "force",
14-
"noEmit": true,
15-
"jsx": "react-jsx",
16-
"verbatimModuleSyntax": true,
17-
18-
/* Linting */
19-
"strict": true,
20-
"noUnusedLocals": true,
21-
"noUnusedParameters": true,
22-
"noFallthroughCasesInSwitch": true,
23-
"noUncheckedSideEffectImports": true
5+
"module": "ESNext"
246
},
25-
"include": ["src"]
7+
"include": ["src"],
8+
"exclude": ["**/*.test.ts*"]
269
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"compilerOptions": {
3+
"useDefineForClassFields": true,
4+
"skipLibCheck": true,
5+
"lib": ["ES2020", "DOM", "DOM.Iterable"],
6+
7+
/* Bundler mode */
8+
"moduleResolution": "bundler",
9+
"allowImportingTsExtensions": true,
10+
"isolatedModules": true,
11+
"moduleDetection": "force",
12+
"noEmit": true,
13+
"jsx": "react-jsx",
14+
"verbatimModuleSyntax": true,
15+
16+
/* Linting */
17+
"strict": true,
18+
"noUnusedLocals": true,
19+
"noUnusedParameters": true,
20+
"noFallthroughCasesInSwitch": true,
21+
"noUncheckedSideEffectImports": true
22+
}
23+
}

exercises/01.sunsetting-jsdom/01.problem.break-jsdom/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"files": [],
33
"references": [
44
{ "path": "./tsconfig.app.json" },
5-
{ "path": "./tsconfig.node.json" }
5+
{ "path": "./tsconfig.node.json" },
6+
{ "path": "./tsconfig.test.json" }
67
]
78
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"extends": "./tsconfig.base.json",
3+
"include": ["vite.config.ts", "**/*.test.ts*"],
4+
"compilerOptions": {
5+
"target": "esnext",
6+
"module": "preserve",
7+
"types": ["@vitest/browser/providers/playwright"]
8+
}
9+
}
Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,9 @@
11
{
2+
"extends": "./tsconfig.base.json",
23
"compilerOptions": {
34
"target": "ES2020",
4-
"useDefineForClassFields": true,
5-
"lib": ["ES2020", "DOM", "DOM.Iterable"],
6-
"module": "ESNext",
7-
"skipLibCheck": true,
8-
9-
/* Bundler mode */
10-
"moduleResolution": "bundler",
11-
"allowImportingTsExtensions": true,
12-
"isolatedModules": true,
13-
"moduleDetection": "force",
14-
"noEmit": true,
15-
"jsx": "react-jsx",
16-
"verbatimModuleSyntax": true,
17-
18-
/* Linting */
19-
"strict": true,
20-
"noUnusedLocals": true,
21-
"noUnusedParameters": true,
22-
"noFallthroughCasesInSwitch": true,
23-
"noUncheckedSideEffectImports": true
5+
"module": "ESNext"
246
},
25-
"include": ["src"]
7+
"include": ["src"],
8+
"exclude": ["**/*.test.ts*"]
269
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"compilerOptions": {
3+
"useDefineForClassFields": true,
4+
"skipLibCheck": true,
5+
"lib": ["ES2020", "DOM", "DOM.Iterable"],
6+
7+
/* Bundler mode */
8+
"moduleResolution": "bundler",
9+
"allowImportingTsExtensions": true,
10+
"isolatedModules": true,
11+
"moduleDetection": "force",
12+
"noEmit": true,
13+
"jsx": "react-jsx",
14+
"verbatimModuleSyntax": true,
15+
16+
/* Linting */
17+
"strict": true,
18+
"noUnusedLocals": true,
19+
"noUnusedParameters": true,
20+
"noFallthroughCasesInSwitch": true,
21+
"noUncheckedSideEffectImports": true
22+
}
23+
}

exercises/01.sunsetting-jsdom/01.solution.break-jsdom/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"files": [],
33
"references": [
44
{ "path": "./tsconfig.app.json" },
5-
{ "path": "./tsconfig.node.json" }
5+
{ "path": "./tsconfig.node.json" },
6+
{ "path": "./tsconfig.test.json" }
67
]
78
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"extends": "./tsconfig.base.json",
3+
"include": ["vite.config.ts", "**/*.test.ts*"],
4+
"compilerOptions": {
5+
"target": "esnext",
6+
"module": "preserve",
7+
"types": ["@vitest/browser/providers/playwright"]
8+
}
9+
}
Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,9 @@
11
{
2+
"extends": "./tsconfig.base.json",
23
"compilerOptions": {
34
"target": "ES2020",
4-
"useDefineForClassFields": true,
5-
"lib": ["ES2020", "DOM", "DOM.Iterable"],
6-
"module": "ESNext",
7-
"skipLibCheck": true,
8-
9-
/* Bundler mode */
10-
"moduleResolution": "bundler",
11-
"allowImportingTsExtensions": true,
12-
"isolatedModules": true,
13-
"moduleDetection": "force",
14-
"noEmit": true,
15-
"jsx": "react-jsx",
16-
"verbatimModuleSyntax": true,
17-
18-
/* Linting */
19-
"strict": true,
20-
"noUnusedLocals": true,
21-
"noUnusedParameters": true,
22-
"noFallthroughCasesInSwitch": true,
23-
"noUncheckedSideEffectImports": true
5+
"module": "ESNext"
246
},
25-
"include": ["src"]
7+
"include": ["src"],
8+
"exclude": ["**/*.test.ts*"]
269
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"compilerOptions": {
3+
"useDefineForClassFields": true,
4+
"skipLibCheck": true,
5+
"lib": ["ES2020", "DOM", "DOM.Iterable"],
6+
7+
/* Bundler mode */
8+
"moduleResolution": "bundler",
9+
"allowImportingTsExtensions": true,
10+
"isolatedModules": true,
11+
"moduleDetection": "force",
12+
"noEmit": true,
13+
"jsx": "react-jsx",
14+
"verbatimModuleSyntax": true,
15+
16+
/* Linting */
17+
"strict": true,
18+
"noUnusedLocals": true,
19+
"noUnusedParameters": true,
20+
"noFallthroughCasesInSwitch": true,
21+
"noUncheckedSideEffectImports": true
22+
}
23+
}

exercises/02.vitest-browser-mode/01.solution.installation-and-setup/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"files": [],
33
"references": [
44
{ "path": "./tsconfig.app.json" },
5-
{ "path": "./tsconfig.node.json" }
5+
{ "path": "./tsconfig.node.json" },
6+
{ "path": "./tsconfig.test.json" }
67
]
78
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"extends": "./tsconfig.base.json",
3+
"include": ["vite.config.ts", "**/*.test.ts*"],
4+
"compilerOptions": {
5+
"target": "esnext",
6+
"module": "preserve",
7+
"types": ["@vitest/browser/providers/playwright"]
8+
}
9+
}
Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,9 @@
11
{
2+
"extends": "./tsconfig.base.json",
23
"compilerOptions": {
34
"target": "ES2020",
4-
"useDefineForClassFields": true,
5-
"lib": ["ES2020", "DOM", "DOM.Iterable"],
6-
"module": "ESNext",
7-
"skipLibCheck": true,
8-
9-
/* Bundler mode */
10-
"moduleResolution": "bundler",
11-
"allowImportingTsExtensions": true,
12-
"isolatedModules": true,
13-
"moduleDetection": "force",
14-
"noEmit": true,
15-
"jsx": "react-jsx",
16-
"verbatimModuleSyntax": true,
17-
18-
/* Linting */
19-
"strict": true,
20-
"noUnusedLocals": true,
21-
"noUnusedParameters": true,
22-
"noFallthroughCasesInSwitch": true,
23-
"noUncheckedSideEffectImports": true
5+
"module": "ESNext"
246
},
25-
"include": ["src"]
7+
"include": ["src"],
8+
"exclude": ["**/*.test.ts*"]
269
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"compilerOptions": {
3+
"useDefineForClassFields": true,
4+
"skipLibCheck": true,
5+
"lib": ["ES2020", "DOM", "DOM.Iterable"],
6+
7+
/* Bundler mode */
8+
"moduleResolution": "bundler",
9+
"allowImportingTsExtensions": true,
10+
"isolatedModules": true,
11+
"moduleDetection": "force",
12+
"noEmit": true,
13+
"jsx": "react-jsx",
14+
"verbatimModuleSyntax": true,
15+
16+
/* Linting */
17+
"strict": true,
18+
"noUnusedLocals": true,
19+
"noUnusedParameters": true,
20+
"noFallthroughCasesInSwitch": true,
21+
"noUncheckedSideEffectImports": true
22+
}
23+
}

exercises/02.vitest-browser-mode/02.solution.migrate-the-test/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"files": [],
33
"references": [
44
{ "path": "./tsconfig.app.json" },
5-
{ "path": "./tsconfig.node.json" }
5+
{ "path": "./tsconfig.node.json" },
6+
{ "path": "./tsconfig.test.json" }
67
]
78
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"extends": "./tsconfig.base.json",
3+
"include": ["vite.config.ts", "**/*.test.ts*"],
4+
"compilerOptions": {
5+
"target": "esnext",
6+
"module": "preserve",
7+
"types": ["@vitest/browser/providers/playwright"]
8+
}
9+
}
Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,9 @@
11
{
2+
"extends": "./tsconfig.base.json",
23
"compilerOptions": {
34
"target": "ES2020",
4-
"useDefineForClassFields": true,
5-
"lib": ["ES2020", "DOM", "DOM.Iterable"],
6-
"module": "ESNext",
7-
"skipLibCheck": true,
8-
9-
/* Bundler mode */
10-
"moduleResolution": "bundler",
11-
"allowImportingTsExtensions": true,
12-
"isolatedModules": true,
13-
"moduleDetection": "force",
14-
"noEmit": true,
15-
"jsx": "react-jsx",
16-
"verbatimModuleSyntax": true,
17-
18-
/* Linting */
19-
"strict": true,
20-
"noUnusedLocals": true,
21-
"noUnusedParameters": true,
22-
"noFallthroughCasesInSwitch": true,
23-
"noUncheckedSideEffectImports": true
5+
"module": "ESNext"
246
},
25-
"include": ["src"]
7+
"include": ["src"],
8+
"exclude": ["**/*.test.ts*"]
269
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"compilerOptions": {
3+
"useDefineForClassFields": true,
4+
"skipLibCheck": true,
5+
"lib": ["ES2020", "DOM", "DOM.Iterable"],
6+
7+
/* Bundler mode */
8+
"moduleResolution": "bundler",
9+
"allowImportingTsExtensions": true,
10+
"isolatedModules": true,
11+
"moduleDetection": "force",
12+
"noEmit": true,
13+
"jsx": "react-jsx",
14+
"verbatimModuleSyntax": true,
15+
16+
/* Linting */
17+
"strict": true,
18+
"noUnusedLocals": true,
19+
"noUnusedParameters": true,
20+
"noFallthroughCasesInSwitch": true,
21+
"noUncheckedSideEffectImports": true
22+
}
23+
}

exercises/02.vitest-browser-mode/03.solution.use-playwright/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"files": [],
33
"references": [
44
{ "path": "./tsconfig.app.json" },
5-
{ "path": "./tsconfig.node.json" }
5+
{ "path": "./tsconfig.node.json" },
6+
{ "path": "./tsconfig.test.json" }
67
]
78
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"extends": "./tsconfig.base.json",
3+
"include": ["vite.config.ts", "**/*.test.ts*"],
4+
"compilerOptions": {
5+
"target": "esnext",
6+
"module": "preserve",
7+
"types": ["@vitest/browser/providers/playwright"]
8+
}
9+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Use DOM assertions
2+
3+
0. Mention that Vitest bundles `@testing-library/jest-dom` so you get DOM assertions like `.toBeVisible()` out of the box!
4+
1. Extend `tsconfig.test.json` with `types` set to `@vitest/browser/matchers` so it picks up the type definitions.
5+
1. Adjust the test to use proper assertions instead of `.toBeTruthy()`.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<title>Vite App</title>
8+
<link rel="preconnect" href="https://fonts.googleapis.com" />
9+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
10+
</head>
11+
<body>
12+
<div id="root"></div>
13+
<script type="module" src="/src/main.tsx"></script>
14+
</body>
15+
</html>

0 commit comments

Comments
 (0)