Skip to content

Commit eede65d

Browse files
committed
fixup: address review feedback
1 parent c1ed85b commit eede65d

File tree

1 file changed

+11
-15
lines changed

1 file changed

+11
-15
lines changed

docs/svelte-testing-library/setup.mdx

+11-15
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ runner that's ESM compatible.
1919
- [`@sveltejs/vite-plugin-svelte`][@sveltejs/vite-plugin-svelte]
2020
- [`vitest`][vitest]
2121
- [`jsdom`][jsdom], [`happy-dom`][happy-dom], or other [Vitest DOM
22-
environment][]
22+
environment][vitest dom]
2323

2424
```bash npm2yarn
2525
npm install --save-dev \
@@ -37,11 +37,10 @@ runner that's ESM compatible.
3737
npm install --save-dev @vitest/ui
3838
```
3939

40-
2. Add a `vitest-setup.js` file to configure cleanup and
41-
[`@testing-library/jest-dom`][@testing-library/jest-dom], if using.
40+
2. Add a `vitest-setup.js` file to optionally set up automatic post-test cleanup
41+
and [`@testing-library/jest-dom`][@testing-library/jest-dom] expect matchers.
4242

43-
```ts
44-
// vitest-setup.js
43+
```ts title="vitest-setup.js"
4544
import '@testing-library/svelte/vitest'
4645
import '@testing-library/jest-dom/vitest'
4746
```
@@ -50,8 +49,7 @@ runner that's ESM compatible.
5049
Svelte files, resolve browser exports during tests, use the [jsdom][] (or
5150
[happy-dom][]) environment, and run your setup file.
5251

53-
```js
54-
// vitest.config.js
52+
```js title="vitest.config.js"
5553
import {defineConfig} from 'vitest/config'
5654
import {svelte} from '@sveltejs/vite-plugin-svelte'
5755

@@ -77,9 +75,9 @@ runner that's ESM compatible.
7775
alternative configuration options to ensure Svelte's browser bundle is used.
7876
:::
7977

80-
4. Add test scipts to your `package.json` to run the tests with Vitest
78+
4. Add test scripts to your `package.json` to run the tests with Vitest
8179

82-
```json
80+
```json title="package.json"
8381
{
8482
"scripts": {
8583
"test": "vitest run",
@@ -103,7 +101,7 @@ runner that's ESM compatible.
103101
[jsdom]: https://github.com/jsdom/jsdom
104102
[happy-dom]: https://github.com/capricorn86/happy-dom
105103
[@vitest/ui]: https://vitest.dev/guide/ui.html
106-
[vitest dom environment]: https://vitest.dev/guide/environment.html
104+
[vitest dom]: https://vitest.dev/guide/environment.html
107105
[testing-library/svelte-testing-library#222]:
108106
https://github.com/testing-library/svelte-testing-library/issues/222
109107

@@ -133,15 +131,13 @@ you must use Jest in [ESM mode][jest esm mode].
133131
2. Add a `jest-setup.js` file to configure
134132
[`@testing-library/jest-dom`][@testing-library/jest-dom], if using.
135133

136-
```ts
137-
// jest-setup.js
134+
```ts title="jest-setup.js"
138135
import '@testing-library/jest-dom'
139136
```
140137

141138
3. Configure Jest to use jsdom, transform Svelte files, and use your setup file
142139

143-
```js
144-
// jest.config.js
140+
```js title="jest.config.js"
145141
module.exports = {
146142
"transform": {
147143
"^.+\\.svelte$": "svelte-jester"
@@ -155,7 +151,7 @@ you must use Jest in [ESM mode][jest esm mode].
155151

156152
4. Add the following to your `package.json`
157153

158-
```json
154+
```json title="package.json"
159155
{
160156
"scripts": {
161157
"test": "npx --node-options=\"--experimental-vm-modules\" jest src",

0 commit comments

Comments
 (0)