Skip to content

Commit 7ff2e51

Browse files
committed
add documentation
1 parent 914a5bb commit 7ff2e51

File tree

3 files changed

+32
-4
lines changed

3 files changed

+32
-4
lines changed

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,21 @@ 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+
### Svelte 5 support
84+
85+
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:
87+
88+
```
89+
export default defineConfig(({ }) => ({
90+
test: {
91+
alias: {
92+
'./pure.js': './svelte5.js'
93+
}
94+
},
95+
}))
96+
```
97+
8398
## Docs
8499

85100
See the [**docs**](https://testing-library.com/docs/svelte-testing-library/intro) over at the Testing Library website.

package.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,8 @@
44
"description": "Simple and complete Svelte testing utilities that encourage good testing practices.",
55
"main": "src/index.js",
66
"exports": {
7-
".": {
8-
"types": "./types/index.d.ts",
9-
"default": "./src/index.js"
10-
},
7+
".": "./src/index.js",
8+
"./svelte5": "./src/svelte5-index.js",
119
"./vitest": {
1210
"default": "./src/vitest.js"
1311
}

src/svelte5-index.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { act, cleanup } from './svelte5.js'
2+
3+
// If we're running in a test runner that supports afterEach
4+
// then we'll automatically run cleanup afterEach test
5+
// this ensures that tests run in isolation from each other
6+
// if you don't like this then either import the `pure` module
7+
// or set the STL_SKIP_AUTO_CLEANUP env variable to 'true'.
8+
if (typeof afterEach === 'function' && !process.env.STL_SKIP_AUTO_CLEANUP) {
9+
afterEach(async () => {
10+
await act()
11+
cleanup()
12+
})
13+
}
14+
15+
export * from './svelte5.js'

0 commit comments

Comments
 (0)