Skip to content

Commit 2944906

Browse files
committed
fix typescript for tests
1 parent e140d4d commit 2944906

File tree

154 files changed

+474
-911
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

154 files changed

+474
-911
lines changed

exercises/01.sunsetting-jsdom/01.problem.break-jsdom/src/app.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useState } from 'react'
2-
import { FilePreview } from './file-preview.jsx'
2+
import { FilePreview } from './file-preview'
33

44
export function App() {
55
const [file, setFile] = useState<File>()
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
22
"extends": "./tsconfig.base.json",
3+
"include": ["src/**/*"],
4+
"exclude": ["src/**/*.test.ts*"],
35
"compilerOptions": {
4-
"target": "ES2020",
5-
"module": "ESNext"
6-
},
7-
"include": ["src"],
8-
"exclude": ["**/*.test.ts*"]
6+
"lib": ["ES2020", "DOM", "DOM.Iterable"],
7+
"jsx": "react-jsx"
8+
}
99
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
{
22
"compilerOptions": {
3+
"target": "ESNext",
4+
"module": "ESNext",
35
"useDefineForClassFields": true,
46
"skipLibCheck": true,
5-
"lib": ["ES2020", "DOM", "DOM.Iterable"],
67

78
/* Bundler mode */
89
"moduleResolution": "bundler",
910
"allowImportingTsExtensions": true,
1011
"isolatedModules": true,
1112
"moduleDetection": "force",
1213
"noEmit": true,
13-
"jsx": "react-jsx",
1414
"verbatimModuleSyntax": true,
1515

1616
/* Linting */
Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,7 @@
11
{
2+
"extends": "./tsconfig.base.json",
23
"compilerOptions": {
3-
"target": "ES2022",
4-
"lib": ["ES2023"],
5-
"module": "ESNext",
6-
"skipLibCheck": true,
7-
8-
/* Bundler mode */
9-
"moduleResolution": "bundler",
10-
"allowImportingTsExtensions": true,
11-
"isolatedModules": true,
12-
"moduleDetection": "force",
13-
"noEmit": true,
14-
15-
/* Linting */
16-
"strict": true,
17-
"noUnusedLocals": false,
18-
"noUnusedParameters": false,
19-
"noFallthroughCasesInSwitch": true,
20-
"noUncheckedSideEffectImports": true
4+
"lib": ["ES2023"]
215
},
226
"include": ["vite.config.ts", "tailwind.config.ts"]
237
}
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
{
2-
"extends": "./tsconfig.base.json",
3-
"include": ["**/*.test.ts*"],
2+
"extends": "./tsconfig.app.json",
3+
"include": ["src/**/*", "src/**/*.test.ts*"],
4+
"exclude": [],
45
"compilerOptions": {
5-
"target": "esnext",
6-
"module": "preserve",
76
"types": ["vitest/globals"]
87
}
98
}
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
22
"extends": "./tsconfig.base.json",
3+
"include": ["src/**/*"],
4+
"exclude": ["src/**/*.test.ts*"],
35
"compilerOptions": {
4-
"target": "ES2020",
5-
"module": "ESNext"
6-
},
7-
"include": ["src"],
8-
"exclude": ["**/*.test.ts*"]
6+
"lib": ["ES2020", "DOM", "DOM.Iterable"],
7+
"jsx": "react-jsx"
8+
}
99
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
{
22
"compilerOptions": {
3+
"target": "ESNext",
4+
"module": "ESNext",
35
"useDefineForClassFields": true,
46
"skipLibCheck": true,
5-
"lib": ["ES2020", "DOM", "DOM.Iterable"],
67

78
/* Bundler mode */
89
"moduleResolution": "bundler",
910
"allowImportingTsExtensions": true,
1011
"isolatedModules": true,
1112
"moduleDetection": "force",
1213
"noEmit": true,
13-
"jsx": "react-jsx",
1414
"verbatimModuleSyntax": true,
1515

1616
/* Linting */
Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,7 @@
11
{
2+
"extends": "./tsconfig.base.json",
23
"compilerOptions": {
3-
"target": "ES2022",
4-
"lib": ["ES2023"],
5-
"module": "ESNext",
6-
"skipLibCheck": true,
7-
8-
/* Bundler mode */
9-
"moduleResolution": "bundler",
10-
"allowImportingTsExtensions": true,
11-
"isolatedModules": true,
12-
"moduleDetection": "force",
13-
"noEmit": true,
14-
15-
/* Linting */
16-
"strict": true,
17-
"noUnusedLocals": false,
18-
"noUnusedParameters": false,
19-
"noFallthroughCasesInSwitch": true,
20-
"noUncheckedSideEffectImports": true
4+
"lib": ["ES2023"]
215
},
226
"include": ["vite.config.ts", "tailwind.config.ts"]
237
}
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
{
2-
"extends": "./tsconfig.base.json",
3-
"include": ["**/*.test.ts*"],
2+
"extends": "./tsconfig.app.json",
3+
"include": ["src/**/*", "src/**/*.test.ts*"],
4+
"exclude": [],
45
"compilerOptions": {
5-
"target": "esnext",
6-
"module": "preserve",
76
"types": ["vitest/globals"]
87
}
98
}

exercises/02.vitest-browser-mode/01.problem.installation-and-setup/README.mdx

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ It's time to take the first step forward Vitest Browser Mode! In this one, you a
77
As the first order of business, I'm going to uninstall the packages I won't be needing anymore:
88

99
```sh nonumber
10-
npm uninstall jsdom @testing-library/react @testing-library/jest-dom/vitest
10+
npm uninstall jsdom @testing-library/react @testing-library/jest-dom
1111
```
1212

1313
> 🦉 I am uninstalling React Testing Library because I won't be using it directly for my in-browser tests. **That doesn't mean its API and practices are gone!** Instead, I will continue using them through the Vitest and Playwright APIs that are inspired by RTL and promote its best practices.
@@ -76,13 +76,20 @@ export default defineConfig({
7676

7777
The last thing that remains is to extend the TypeScript configuration to recognize DOM-specific matches, like `expect().toBeVisible()` as they come built-in in Vitest.
7878

79-
```json filename=tsconfig.test.json add=10
79+
First, I will remove the `import '@testing-library/jest-dom/vitest'` import we previously had in the test:
80+
81+
```tsx filename=file-preview.test.tsx remove=1
82+
import '@testing-library/jest-dom/vitest'
83+
```
84+
85+
And replace it with a type reference to Vitest's browser matchers in `tsconfig.test.json`:
86+
87+
```json filename=tsconfig.test.json add=9
8088
{
81-
"extends": "./tsconfig.base.json",
82-
"include": ["**/*.test.ts*"],
89+
"extends": "./tsconfig.app.json",
90+
"include": ["src/**/*", "src/**/*.test.ts*"],
91+
"exclude": [],
8392
"compilerOptions": {
84-
"target": "esnext",
85-
"module": "preserve",
8693
"types": [
8794
"vitest/globals",
8895
// 👇

0 commit comments

Comments
 (0)