You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
5. This is optional but it is recommended, you can install
55
+
[jest-dom](https://github.com/testing-library/jest-dom) to add handy
56
+
assertions to Jest
57
+
58
+
5.1 Install `jest-dom`
59
+
60
+
```
61
+
npm install --save-dev @testing-library/jest-dom
62
+
```
63
+
64
+
5.2 import `@testing-library/jest-dom` at the start of your test files
65
+
66
+
```js
67
+
import'@testing-library/jest-dom';
68
+
```
69
+
70
+
6. Create your component and a test file (checkout the rest of the docs to see how)
71
+
and run the following command to run the tests.
72
+
73
+
```
74
+
npm run test
75
+
```
76
+
### SvelteKit
77
+
78
+
To use Vitest with SvelteKit install `vitest-svelte-kit`, which includes a preconfigured Vitest configuration for SvelteKit projects.
79
+
You can take a look at the [`vitest-svelte-kit` configuration docs](https://github.com/nickbreaton/vitest-svelte-kit/tree/master/packages/vitest-svelte-kit#configuring) for further instructions.
80
+
10
81
## Jest
11
82
12
83
1. Install Jest & jest-environment-jsdom
@@ -99,79 +170,14 @@ with any testing framework and runner you're comfortable with.
99
170
```
100
171
npm run test
101
172
```
102
-
## Vitest
103
-
1. Install Vitest and jsdom
104
-
105
-
```
106
-
npm install --save-dev vitest jsdom
107
-
```
108
-
109
-
2. Add the following to your `package.json`
110
-
111
-
```json
112
-
{
113
-
"scripts": {
114
-
"test": "vitest run src",
115
-
"test:watch": "vitest src"
116
-
}
117
-
}
118
-
```
119
-
120
-
3. You'll need to compile the Svelte components before using them in Vitest, so
121
-
you need to install
122
-
[@sveltejs/vite-plugin-svelte](https://github.com/sveltejs/vite-plugin-svelte) and Vite
123
-
124
-
125
-
```
126
-
npm install --save-dev @sveltejs/vite-plugin-svelte vite
127
-
```
128
-
129
-
4. Add a `vitest.config.ts` configuration file to the root of your project
0 commit comments