Skip to content

Commit fe2e387

Browse files
committed
fixup: review feedback + README
1 parent 64648fe commit fe2e387

File tree

4 files changed

+33
-10
lines changed

4 files changed

+33
-10
lines changed

README.md

+30-7
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<p>Simple and complete Svelte testing utilities that encourage good testing practices.</p>
1414

1515
[**Read The Docs**](https://testing-library.com/docs/svelte-testing-library/intro) |
16-
[Edit the docs](https://github.com/alexkrolick/testing-library-docs)
16+
[Edit the docs](https://github.com/testing-library/testing-library-docs)
1717

1818
<!-- prettier-ignore-start -->
1919
[![Build Status][build-badge]][build]
@@ -80,19 +80,42 @@ This library has `peerDependencies` listings for `svelte >= 3`.
8080
You may also be interested in installing `@testing-library/jest-dom` so you can use
8181
[the custom jest matchers](https://github.com/testing-library/jest-dom).
8282

83+
## Setup
84+
85+
We recommend using `@testing-library/svelte` with [Vitest][] as your test runner. To get started, add the `svelteTesting` plugin to your Vite or Vitest config.
86+
87+
```diff
88+
// vite.config.js
89+
import { svelte } from '@sveltejs/vite-plugin-svelte'
90+
+ import { svelteTesting } from '@testing-library/svelte/vite'
91+
92+
export default defineConfig({
93+
plugins: [
94+
svelte(),
95+
+ svelteTesting(),
96+
]
97+
});
98+
```
99+
100+
See the [setup docs][] for more detailed setup instructions, including for other test runners like Jest.
101+
102+
[vitest]: https://vitest.dev/
103+
[setup docs]: https://testing-library.com/docs/svelte-testing-library/setup
104+
83105
### Svelte 5 support
84106

85107
If you are riding the bleeding edge of Svelte 5, you'll need to either
86-
import from `@testing-library/svelte/svelte5` instead of `@testing-library/svelte`, or have your `vite.config.js` contains the following alias:
108+
import from `@testing-library/svelte/svelte5` instead of `@testing-library/svelte`, or add an alias to your `vite.config.js`:
87109

88-
```
89-
export default defineConfig(({ }) => ({
110+
```js
111+
export default defineConfig({
112+
plugins: [svelte(), svelteTesting()],
90113
test: {
91114
alias: {
92-
'@testing-library/svelte': '@testing-library/svelte/svelte5'
93-
}
115+
'@testing-library/svelte': '@testing-library/svelte/svelte5',
116+
},
94117
},
95-
}))
118+
})
96119
```
97120

98121
## Docs

package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
"./vitest": {
1616
"default": "./src/vitest.js"
1717
},
18-
"./vite-plugin": {
19-
"types": "./src/vite-plugin.d.ts",
20-
"default": "./src/vite-plugin.js"
18+
"./vite": {
19+
"types": "./src/vite.d.ts",
20+
"default": "./src/vite.js"
2121
}
2222
},
2323
"type": "module",
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)