12
12
13
13
<p >Simple and complete Svelte testing utilities that encourage good testing practices.</p >
14
14
15
- [ ** Read The Docs** ] ( https://testing-library.com/docs/svelte-testing-library/intro ) |
16
- [ Edit the docs] ( https://github.com/testing-library/testing-library-docs )
15
+ [ ** Read The Docs** ] [ stl-docs ] | [ Edit the docs] [ stl-docs-repo ]
17
16
18
17
<!-- prettier-ignore-start -->
19
18
[ ![ Build Status] [ build-badge ]] [ build ]
20
19
[ ![ Code Coverage] [ coverage-badge ]] [ coverage ]
21
- [ ![ version] [ version-badge ]] [ package ] [ ![ downloads] [ downloads-badge ]] [ npmtrends ]
20
+ [ ![ version] [ version-badge ]] [ package ]
21
+ [ ![ downloads] [ downloads-badge ]] [ downloads ]
22
22
[ ![ MIT License] [ license-badge ]] [ license ]
23
23
24
- [ ![ All Contributors] ( https://img.shields.io/badge/all_contributors-8-orange.svg?style=flat-square )] ( #contributors- )
25
- [ ![ PRs Welcome] [ prs-badge ]] [ prs ] [ ![ Code of Conduct] [ coc-badge ]] [ coc ]
24
+ [ ![ All Contributors] [ contributors-badge ]] [ contributors ]
25
+ [ ![ PRs Welcome] [ prs-badge ]] [ prs ]
26
+ [ ![ Code of Conduct] [ coc-badge ]] [ coc ]
26
27
[ ![ Discord] [ discord-badge ]] [ discord ]
27
28
28
29
[ ![ Watch on GitHub] [ github-watch-badge ]] [ github-watch ]
33
34
34
35
<hr />
35
36
37
+ [ stl-docs ] : https://testing-library.com/docs/svelte-testing-library/intro
38
+ [ stl-docs-repo ] : https://github.com/testing-library/testing-library-docs
39
+ [ build-badge ] : https://img.shields.io/github/actions/workflow/status/testing-library/svelte-testing-library/release.yml?style=flat-square
40
+ [ build ] : https://github.com/testing-library/svelte-testing-library/actions
41
+ [ coverage-badge ] : https://img.shields.io/codecov/c/github/testing-library/svelte-testing-library.svg?style=flat-square
42
+ [ coverage ] : https://codecov.io/github/testing-library/svelte-testing-library
43
+ [ version-badge ] : https://img.shields.io/npm/v/@testing-library/svelte.svg?style=flat-square
44
+ [ package ] : https://www.npmjs.com/package/@testing-library/svelte
45
+ [ downloads-badge ] : https://img.shields.io/npm/dm/@testing-library/svelte.svg?style=flat-square
46
+ [ downloads ] : http://www.npmtrends.com/@testing-library/svelte
47
+ [ license-badge ] : https://img.shields.io/github/license/testing-library/svelte-testing-library?color=b&style=flat-square
48
+ [ license ] : https://github.com/testing-library/svelte-testing-library/blob/main/LICENSE
49
+ [ contributors-badge ] : https://img.shields.io/badge/all_contributors-8-orange.svg?style=flat-square
50
+ [ contributors ] : #contributors
51
+ [ prs-badge ] : https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square
52
+ [ prs ] : http://makeapullrequest.com
53
+ [ coc-badge ] : https://img.shields.io/badge/code%20of-conduct-ff69b4.svg?style=flat-square
54
+ [ coc ] : https://github.com/testing-library/svelte-testing-library/blob/main/CODE_OF_CONDUCT.md
55
+ [ discord-badge ] : https://img.shields.io/discord/723559267868737556.svg?color=7389D8&labelColor=6A7EC2&logo=discord&logoColor=ffffff&style=flat-square
56
+ [ discord ] : https://discord.gg/testing-library
57
+ [ github-watch-badge ] : https://img.shields.io/github/watchers/testing-library/svelte-testing-library.svg?style=social
58
+ [ github-watch ] : https://github.com/testing-library/svelte-testing-library/watchers
59
+ [ github-star-badge ] : https://img.shields.io/github/stars/testing-library/svelte-testing-library.svg?style=social
60
+ [ github-star ] : https://github.com/testing-library/svelte-testing-library/stargazers
61
+ [ twitter ] : https://twitter.com/intent/tweet?text=Check%20out%20svelte-testing-library%20by%20%40@TestingLib%20https%3A%2F%2Fgithub.com%2Ftesting-library%2Fsvelte-testing-library%20%F0%9F%91%8D
62
+ [ twitter-badge ] : https://img.shields.io/twitter/url/https/github.com/testing-library/svelte-testing-library.svg?style=social
63
+
36
64
## Table of Contents
37
65
38
66
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
41
69
- [ The Problem] ( #the-problem )
42
70
- [ This Solution] ( #this-solution )
43
71
- [ Installation] ( #installation )
72
+ - [ Setup] ( #setup )
44
73
- [ Docs] ( #docs )
45
74
- [ Issues] ( #issues )
46
75
- [ 🐛 Bugs] ( #-bugs )
47
76
- [ 💡 Feature Requests] ( #-feature-requests )
48
77
- [ ❓ Questions] ( #-questions )
49
78
- [ Contributors] ( #contributors )
50
- - [ LICENSE] ( #license )
51
79
52
80
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
53
81
54
82
## The Problem
55
83
56
- You want to write tests for your Svelte components so that they avoid including implementation
57
- details, and are maintainable in the long run.
84
+ You want to write maintainable tests for your [ Svelte] [ svelte ] components.
85
+
86
+ [ svelte ] : https://svelte.dev/
58
87
59
88
## This Solution
60
89
61
- The ` svelte- testing-library` is a very lightweight solution for testing Svelte
62
- components. It provides light utility functions on top of ` svelte ` and
63
- ` dom- testing-library` , in a way that encourages better testing practices. Its
64
- primary guiding principle is:
90
+ ` @ testing-library/svelte ` is a lightweight library for testing Svelte
91
+ components. It provides functions on top of ` svelte ` and
92
+ ` @ testing-library/dom ` so you can mount Svelte components and query their
93
+ rendered output in the DOM. Its primary guiding principle is:
65
94
66
95
> [ The more your tests resemble the way your software is used, the more
67
96
> confidence they can give you.] [ guiding-principle ]
68
97
98
+ [ guiding-principle ] : https://twitter.com/kentcdodds/status/977018512689455106
99
+
69
100
## Installation
70
101
71
102
This module is distributed via [ npm] [ npm ] which is bundled with [ node] [ node ] and
72
103
should be installed as one of your project's ` devDependencies ` :
73
104
74
- ```
105
+ ``` shell
75
106
npm install --save-dev @testing-library/svelte
76
107
```
77
108
78
- This library has ` peerDependencies ` listings for ` svelte >= 3 ` .
109
+ This library supports ` svelte ` versions ` 3 ` , ` 4 ` , and ` 5 ` .
110
+
111
+ You may also be interested in installing ` @testing-library/jest-dom ` so you can
112
+ use [ the custom jest matchers] [ jest-dom ] .
79
113
80
- You may also be interested in installing ` @testing-library/jest-dom ` so you can use
81
- [ the custom jest matchers] ( https://github.com/testing-library/jest-dom ) .
114
+ [ npm ] : https://www.npmjs.com/
115
+ [ node ] : https://nodejs.org
116
+ [ jest-dom ] : https://github.com/testing-library/jest-dom
82
117
83
118
## Setup
84
119
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.
120
+ We recommend using ` @testing-library/svelte ` with [ Vitest] [ ] as your test
121
+ runner. To get started, add the ` svelteTesting ` plugin to your Vite or Vitest
122
+ config.
86
123
87
124
``` diff
88
125
// vite.config.js
@@ -97,49 +134,40 @@ We recommend using `@testing-library/svelte` with [Vitest][] as your test runner
97
134
});
98
135
```
99
136
100
- See the [ setup docs] [ ] for more detailed setup instructions, including for other test runners like Jest.
137
+ See the [ setup docs] [ ] for more detailed setup instructions, including for other
138
+ test runners like Jest.
101
139
102
140
[ vitest ] : https://vitest.dev/
103
141
[ setup docs ] : https://testing-library.com/docs/svelte-testing-library/setup
104
142
105
- ### Svelte 5 support
106
-
107
- If you are riding the bleeding edge of Svelte 5, you'll need to either
108
- import from ` @testing-library/svelte/svelte5 ` instead of ` @testing-library/svelte ` , or add an alias to your ` vite.config.js ` :
109
-
110
- ``` js
111
- export default defineConfig ({
112
- plugins: [svelte (), svelteTesting ()],
113
- test: {
114
- alias: {
115
- ' @testing-library/svelte' : ' @testing-library/svelte/svelte5' ,
116
- },
117
- },
118
- })
119
- ```
120
-
121
143
## Docs
122
144
123
- See the [ ** docs** ] ( https://testing-library.com/ docs/svelte-testing-library/intro ) over at the Testing Library website.
145
+ See the [ ** docs** ] [ stl- docs] over at the Testing Library website.
124
146
125
147
## Issues
126
148
127
149
_ Looking to contribute? Look for the [ Good First Issue] [ good-first-issue ]
128
150
label._
129
151
152
+ [ good-first-issue ] : https://github.com/testing-library/svelte-testing-library/issues?utf8=✓&q=is%3Aissue+is%3Aopen+sort%3Areactions-%2B1-desc+label%3A"good+first+issue"+
153
+
130
154
### 🐛 Bugs
131
155
132
156
Please file an issue for bugs, missing documentation, or unexpected behavior.
133
157
134
158
[ ** See Bugs** ] [ bugs ]
135
159
160
+ [ bugs ] : https://github.com/testing-library/svelte-testing-library/issues?q=is%3Aissue+is%3Aopen+label%3Abug+sort%3Acreated-desc
161
+
136
162
### 💡 Feature Requests
137
163
138
164
Please file an issue to suggest new features. Vote on feature requests by adding
139
165
a 👍. This helps maintainers prioritize what to work on.
140
166
141
167
[ ** See Feature Requests** ] [ requests ]
142
168
169
+ [ requests ] : https://github.com/testing-library/svelte-testing-library/issues?q=is%3Aissue+sort%3Areactions-%2B1-desc+label%3Aenhancement+is%3Aopen
170
+
143
171
### ❓ Questions
144
172
145
173
For questions related to using the library, please visit a support community
@@ -148,6 +176,8 @@ instead of filing an issue on GitHub.
148
176
- [ Discord] [ discord ]
149
177
- [ Stack Overflow] [ stackoverflow ]
150
178
179
+ [ stackoverflow ] : https://stackoverflow.com/questions/tagged/svelte-testing-library
180
+
151
181
## Contributors
152
182
153
183
Thanks goes to these people ([ emoji key] [ emojis ] ):
@@ -189,44 +219,5 @@ Thanks goes to these people ([emoji key][emojis]):
189
219
This project follows the [ all-contributors] [ all-contributors ] specification.
190
220
Contributions of any kind welcome!
191
221
192
- ## LICENSE
193
-
194
- [ MIT] ( LICENSE )
195
-
196
- <!-- prettier-ignore-start -->
197
-
198
- [ npm ] : https://www.npmjs.com/
199
- [ node ] : https://nodejs.org
200
- [ build-badge ] : https://img.shields.io/github/actions/workflow/status/testing-library/svelte-testing-library/release.yml?style=flat-square
201
- [ build ] : https://github.com/testing-library/svelte-testing-library/actions
202
- [ coverage-badge ] : https://img.shields.io/codecov/c/github/testing-library/svelte-testing-library.svg?style=flat-square
203
- [ coverage ] : https://codecov.io/github/testing-library/svelte-testing-library
204
- [ version-badge ] : https://img.shields.io/npm/v/@testing-library/svelte.svg?style=flat-square
205
- [ package ] : https://www.npmjs.com/package/@testing-library/svelte
206
- [ downloads-badge ] : https://img.shields.io/npm/dm/@testing-library/svelte.svg?style=flat-square
207
- [ npmtrends ] : http://www.npmtrends.com/@testing-library/svelte
208
- [ discord-badge ] : https://img.shields.io/discord/723559267868737556.svg?color=7389D8&labelColor=6A7EC2&logo=discord&logoColor=ffffff&style=flat-square
209
- [ discord ] : https://discord.gg/testing-library
210
- [ license-badge ] : https://img.shields.io/github/license/testing-library/svelte-testing-library?color=b&style=flat-square
211
- [ license ] : https://github.com/testing-library/svelte-testing-library/blob/main/LICENSE
212
- [ prs-badge ] : https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square
213
- [ prs ] : http://makeapullrequest.com
214
- [ donate-badge ] : https://img.shields.io/badge/$-support-green.svg?style=flat-square
215
- [ coc-badge ] : https://img.shields.io/badge/code%20of-conduct-ff69b4.svg?style=flat-square
216
- [ coc ] : https://github.com/testing-library/svelte-testing-library/blob/main/CODE_OF_CONDUCT.md
217
- [ github-watch-badge ] : https://img.shields.io/github/watchers/testing-library/svelte-testing-library.svg?style=social
218
- [ github-watch ] : https://github.com/testing-library/svelte-testing-library/watchers
219
- [ github-star-badge ] : https://img.shields.io/github/stars/testing-library/svelte-testing-library.svg?style=social
220
- [ github-star ] : https://github.com/testing-library/svelte-testing-library/stargazers
221
- [ twitter ] : https://twitter.com/intent/tweet?text=Check%20out%20svelte-testing-library%20by%20%40@TestingLib%20https%3A%2F%2Fgithub.com%2Ftesting-library%2Fsvelte-testing-library%20%F0%9F%91%8D
222
- [ twitter-badge ] : https://img.shields.io/twitter/url/https/github.com/testing-library/svelte-testing-library.svg?style=social
223
222
[ emojis ] : https://github.com/all-contributors/all-contributors#emoji-key
224
223
[ all-contributors ] : https://github.com/all-contributors/all-contributors
225
- [ set-immediate ] : https://developer.mozilla.org/en-US/docs/Web/API/Window/setImmediate
226
- [ guiding-principle ] : https://twitter.com/kentcdodds/status/977018512689455106
227
- [ bugs ] : https://github.com/testing-library/svelte-testing-library/issues?q=is%3Aissue+is%3Aopen+label%3Abug+sort%3Acreated-desc
228
- [ requests ] : https://github.com/testing-library/svelte-testing-library/issues?q=is%3Aissue+sort%3Areactions-%2B1-desc+label%3Aenhancement+is%3Aopen
229
- [ good-first-issue ] : https://github.com/testing-library/svelte-testing-library/issues?utf8=✓&q=is%3Aissue+is%3Aopen+sort%3Areactions-%2B1-desc+label%3A"good+first+issue"+
230
- [ stackoverflow ] : https://stackoverflow.com/questions/tagged/svelte-testing-library
231
-
232
- <!-- prettier-ignore-end -->
0 commit comments