@testing-library/svelte-core 1.0.0-next.4 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -11
- package/package.json +4 -9
package/README.md
CHANGED
|
@@ -22,27 +22,35 @@ afterwards.
|
|
|
22
22
|
```ts
|
|
23
23
|
import { beforeEach } from 'vitest'
|
|
24
24
|
import * as SvelteCore from '@testing-library/svelte-core'
|
|
25
|
+
import type {
|
|
26
|
+
Component,
|
|
27
|
+
Exports,
|
|
28
|
+
Rerender,
|
|
29
|
+
} from '@testing-library/svelte-core/types'
|
|
25
30
|
|
|
26
|
-
import { bindQueries, type
|
|
31
|
+
import { bindQueries, type Queries } from './bring-your-own-queries.js'
|
|
27
32
|
|
|
28
33
|
beforeEach(() => {
|
|
29
34
|
SvelteCore.cleanup()
|
|
30
35
|
})
|
|
31
36
|
|
|
32
|
-
export interface RenderResult<
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
37
|
+
export interface RenderResult<C extends Component> extends Queries {
|
|
38
|
+
container: HTMLElement
|
|
39
|
+
component: Exports<C>
|
|
40
|
+
rerender: Rerender<C>
|
|
41
|
+
unmount: () => void
|
|
36
42
|
}
|
|
37
43
|
|
|
38
44
|
export const render = <C extends SvelteCore.Component>(
|
|
39
45
|
Component: SvelteCore.ComponentImport<C>,
|
|
40
46
|
options: SvelteCore.ComponentOptions<C>
|
|
41
47
|
): RenderResult<C> => {
|
|
42
|
-
const
|
|
43
|
-
|
|
48
|
+
const { baseElement, component, container, rerender, unmount } =
|
|
49
|
+
SvelteCore.render(Component, options)
|
|
50
|
+
|
|
51
|
+
const queries = bindQueries(baseElement)
|
|
44
52
|
|
|
45
|
-
return {
|
|
53
|
+
return { component, container, rerender, unmount, ...queries }
|
|
46
54
|
}
|
|
47
55
|
```
|
|
48
56
|
|
|
@@ -53,7 +61,7 @@ export const render = <C extends SvelteCore.Component>(
|
|
|
53
61
|
Set up the document and mount a component into that document.
|
|
54
62
|
|
|
55
63
|
```ts
|
|
56
|
-
const { baseElement, container, component,
|
|
64
|
+
const { baseElement, container, component, rerender, unmount } = render(
|
|
57
65
|
Component,
|
|
58
66
|
componentOptions,
|
|
59
67
|
setupOptions
|
|
@@ -93,7 +101,10 @@ const { baseElement, container, component, unmount, rerender } = render(
|
|
|
93
101
|
Validate options and prepare document elements for rendering.
|
|
94
102
|
|
|
95
103
|
```ts
|
|
96
|
-
const { baseElement,
|
|
104
|
+
const { baseElement, container, mountOptions } = setup(
|
|
105
|
+
componentOptions,
|
|
106
|
+
setupOptions
|
|
107
|
+
)
|
|
97
108
|
```
|
|
98
109
|
|
|
99
110
|
| Argument | Type | Description |
|
|
@@ -112,7 +123,7 @@ const { baseElement, target, mountOptions } = setup(options, renderOptions)
|
|
|
112
123
|
Mount a Svelte component into the document.
|
|
113
124
|
|
|
114
125
|
```ts
|
|
115
|
-
const { component, unmount, rerender } = mount(Component,
|
|
126
|
+
const { component, unmount, rerender } = mount(Component, mountOptions)
|
|
116
127
|
```
|
|
117
128
|
|
|
118
129
|
| Argument | Type | Description |
|
package/package.json
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@testing-library/svelte-core",
|
|
3
|
-
"version": "1.0.0
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "Core rendering and cleanup logic for Svelte testing utilities.",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
8
|
-
"svelte": "./src/index.js",
|
|
9
8
|
"default": "./src/index.js"
|
|
10
9
|
},
|
|
11
10
|
"./types": {
|
|
@@ -27,16 +26,12 @@
|
|
|
27
26
|
"node": ">=16"
|
|
28
27
|
},
|
|
29
28
|
"keywords": [
|
|
30
|
-
"
|
|
29
|
+
"tdd",
|
|
31
30
|
"svelte",
|
|
32
31
|
"ui",
|
|
33
|
-
"dom",
|
|
34
|
-
"jsdom",
|
|
35
32
|
"unit",
|
|
36
|
-
"
|
|
37
|
-
"functional"
|
|
38
|
-
"end-to-end",
|
|
39
|
-
"e2e"
|
|
33
|
+
"component",
|
|
34
|
+
"functional"
|
|
40
35
|
],
|
|
41
36
|
"files": [
|
|
42
37
|
"dist",
|