1212
1313<p >Simple and complete Svelte testing utilities that encourage good testing practices.</p >
1414
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 ] 
1716
1817<!--  prettier-ignore-start --> 
1918[ ![ Build Status] [ build-badge ]] [ build ] 
2019[ ![ Code Coverage] [ coverage-badge ]] [ coverage ] 
21- [ ![ version] [ version-badge ]] [ package ]  [ ![ downloads] [ downloads-badge ]] [ npmtrends ] 
20+ [ ![ version] [ version-badge ]] [ package ] 
21+ [ ![ downloads] [ downloads-badge ]] [ downloads ] 
2222[ ![ MIT License] [ license-badge ]] [ license ] 
2323
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 ] 
2627[ ![ Discord] [ discord-badge ]] [ discord ] 
2728
2829[ ![ Watch on GitHub] [ github-watch-badge ]] [ github-watch ] 
3334
3435<hr  />
3536
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+ 
3664## Table of Contents  
3765
3866<!--  START doctoc generated TOC please keep comment here to allow auto update --> 
4169-  [ The Problem] ( #the-problem ) 
4270-  [ This Solution] ( #this-solution ) 
4371-  [ Installation] ( #installation ) 
72+ -  [ Setup] ( #setup ) 
4473-  [ Docs] ( #docs ) 
4574-  [ Issues] ( #issues ) 
4675  -  [ 🐛 Bugs] ( #-bugs ) 
4776  -  [ 💡 Feature Requests] ( #-feature-requests ) 
4877  -  [ ❓ Questions] ( #-questions ) 
4978-  [ Contributors] ( #contributors ) 
50- -  [ LICENSE] ( #license ) 
5179
5280<!--  END doctoc generated TOC please keep comment here to allow auto update --> 
5381
5482## The Problem  
5583
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/ 
5887
5988## This Solution  
6089
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:
6594
6695>  [ The more your tests resemble the way your software is used, the more
6796>  confidence they can give you.] [ guiding-principle ] 
6897
98+ [ guiding-principle ] : https://twitter.com/kentcdodds/status/977018512689455106 
99+ 
69100## Installation  
70101
71102This module is distributed via [ npm] [ npm ]  which is bundled with [ node] [ node ]  and
72103should be installed as one of your project's ` devDependencies ` :
73104
74- ``` 
105+ ``` shell 
75106npm install --save-dev @testing-library/svelte
76107``` 
77108
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 ] .
79113
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 
82117
83118## Setup  
84119
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.
86123
87124``` diff 
88125  // vite.config.js
@@ -97,49 +134,40 @@ We recommend using `@testing-library/svelte` with [Vitest][] as your test runner
97134  });
98135``` 
99136
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.
101139
102140[ vitest ] : https://vitest.dev/ 
103141[ setup docs ] : https://testing-library.com/docs/svelte-testing-library/setup 
104142
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- 
121143## Docs  
122144
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.
124146
125147## Issues  
126148
127149_ Looking to contribute? Look for the [ Good First Issue] [ good-first-issue ] 
128150label._ 
129151
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+ 
130154### 🐛 Bugs  
131155
132156Please file an issue for bugs, missing documentation, or unexpected behavior.
133157
134158[ ** See Bugs** ] [ bugs ] 
135159
160+ [ bugs ] : https://github.com/testing-library/svelte-testing-library/issues?q=is%3Aissue+is%3Aopen+label%3Abug+sort%3Acreated-desc 
161+ 
136162### 💡 Feature Requests  
137163
138164Please file an issue to suggest new features. Vote on feature requests by adding
139165a 👍. This helps maintainers prioritize what to work on.
140166
141167[ ** See Feature Requests** ] [ requests ] 
142168
169+ [ requests ] : https://github.com/testing-library/svelte-testing-library/issues?q=is%3Aissue+sort%3Areactions-%2B1-desc+label%3Aenhancement+is%3Aopen 
170+ 
143171### ❓ Questions  
144172
145173For questions related to using the library, please visit a support community
@@ -148,6 +176,8 @@ instead of filing an issue on GitHub.
148176-  [ Discord] [ discord ] 
149177-  [ Stack Overflow] [ stackoverflow ] 
150178
179+ [ stackoverflow ] : https://stackoverflow.com/questions/tagged/svelte-testing-library 
180+ 
151181## Contributors  
152182
153183Thanks goes to these people ([ emoji key] [ emojis ] ):
@@ -189,44 +219,5 @@ Thanks goes to these people ([emoji key][emojis]):
189219This project follows the [ all-contributors] [ all-contributors ]  specification.
190220Contributions of any kind welcome!
191221
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 
223222[ emojis ] : https://github.com/all-contributors/all-contributors#emoji-key 
224223[ 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