@@ -68,19 +68,20 @@ const { baseElement, container, component, rerender, unmount } = render(
6868)
6969```
7070
71- | Argument | Type | Description |
72- | ------------------ | ------------------------------------------------------- | --------------------------------------------- |
73- | ` Component ` | [ Svelte component] [ svelte-component-docs ] | An imported Svelte component |
74- | ` componentOptions ` | ` Props ` or partial [ ` mount ` options] [ svelte-mount-docs ] | Options for how the component will be mounted |
75- | ` setupOptions ` | ` { baseElement?: HTMLElement } ` | Optionally override ` baseElement ` |
76-
77- | Result | Type | Description | Default |
78- | ------------- | ------------------------------------------ | ---------------------------------------- | ----------------------------------- |
79- | ` baseElement ` | ` HTMLElement ` | The base element | ` document.body ` |
80- | ` container ` | ` HTMLElement ` | The component's immediate parent element | ` <div> ` appended to ` document.body ` |
81- | ` component ` | [ component exports] [ svelte-mount-docs ] | The component's exports from ` mount ` | N/A |
82- | ` rerender ` | ` (props: Partial<Props>) => Promise<void> ` | Update the component's props | N/A |
83- | ` unmount ` | ` () => void ` | Unmount the component from the document | N/A |
71+ | Argument | Type | Description |
72+ | ------------------ | ------------------------------------------------------- | ------------------------------------------------------- |
73+ | ` Component ` | [ Svelte component] [ svelte-component-docs ] | An imported Svelte component |
74+ | ` componentOptions ` | ` Props ` or partial [ ` mount ` options] [ svelte-mount-docs ] | Options for how the component will be mounted |
75+ | ` setupOptions ` | [ ` SetupOptions ` ] ( #setup ) | Optionally override ` baseElement ` or wrap the component |
76+
77+ | Result | Type | Description | Default |
78+ | ------------- | ------------------------------------------ | -------------------------------------------------- | ----------------------------------- |
79+ | ` baseElement ` | ` HTMLElement ` | The base element | ` document.body ` |
80+ | ` container ` | ` HTMLElement ` | The component's immediate parent element | ` <div> ` appended to ` document.body ` |
81+ | ` component ` | [ component exports] [ svelte-mount-docs ] | The component's exports from ` mount ` | N/A |
82+ | ` wrapper ` | [ component exports] [ svelte-mount-docs ] | The wrapper's exports, if a ` wrapper ` was provided | ` undefined ` |
83+ | ` rerender ` | ` (props: Partial<Props>) => Promise<void> ` | Update the component's props | N/A |
84+ | ` unmount ` | ` () => void ` | Unmount the component from the document | N/A |
8485
8586> \[ !TIP]
8687> Calling ` render ` is equivalent to calling [ ` setup ` ] ( #setup ) followed by [ ` mount ` ] ( #mount )
@@ -90,7 +91,11 @@ const { baseElement, container, component, rerender, unmount } = render(
9091> componentOptions ,
9192> setupOptions
9293> )
93- > const { component, rerender, unmount } = mount (Component , mountOptions )
94+ > const { component, rerender, unmount } = mount (
95+ > Component ,
96+ > mountOptions ,
97+ > setupOptions
98+ > )
9499> ` ` `
95100
96101[svelte-component-docs]: https://svelte.dev/docs/svelte-components
@@ -110,7 +115,15 @@ const { baseElement, container, mountOptions } = setup(
110115| Argument | Type | Description |
111116| ------------------ | ------------------------------------------------------- | --------------------------------------------- |
112117| ` componentOptions ` | ` Props ` or partial [ ` mount ` options] [ svelte-mount-docs ] | Options for how the component will be mounted |
113- | ` setupOptions ` | ` { baseElement?: HTMLElement } ` | Optionally override ` baseElement ` |
118+ | ` setupOptions ` | ` SetupOptions ` | Configure the document and wrap the component |
119+
120+ ` setupOptions ` accepts the following fields, all optional:
121+
122+ | Field | Type | Description | Default |
123+ | -------------- | ----------------------------------------- | --------------------------------------------------------------------- | --------------- |
124+ | ` baseElement ` | ` HTMLElement ` | The base element to bind queries to | ` document.body ` |
125+ | ` wrapper ` | [ Svelte component] [ svelte-component-docs ] | A component to wrap the component under test, e.g. a context provider | ` undefined ` |
126+ | ` wrapperProps ` | ` Props ` | Props to pass to the ` wrapper ` component | ` undefined ` |
114127
115128| Result | Type | Description | Default |
116129| -------------- | ------------------------------------ | ---------------------------------------- | ----------------------------------- |
@@ -123,19 +136,25 @@ const { baseElement, container, mountOptions } = setup(
123136Mount a Svelte component into the document.
124137
125138``` ts
126- const { component, unmount, rerender } = mount (Component , mountOptions )
139+ const { component, wrapper, unmount, rerender } = mount (
140+ Component ,
141+ mountOptions ,
142+ setupOptions
143+ )
127144```
128145
129- | Argument | Type | Description |
130- | -------------- | ----------------------------------------- | -------------------------------------------- |
131- | ` Component ` | [ Svelte component] [ svelte-component-docs ] | An imported Svelte component |
132- | ` mountOptions ` | [ component options] [ svelte-mount-docs ] | Options to pass to Svelte's ` mount ` function |
133-
134- | Result | Type | Description |
135- | ----------- | ------------------------------------------ | --------------------------------------- |
136- | ` component ` | [ component exports] [ svelte-mount-docs ] | The component's exports from ` mount ` |
137- | ` unmount ` | ` () => void ` | Unmount the component from the document |
138- | ` rerender ` | ` (props: Partial<Props>) => Promise<void> ` | Update the component's props |
146+ | Argument | Type | Description |
147+ | -------------- | ----------------------------------------- | --------------------------------------------------------- |
148+ | ` Component ` | [ Svelte component] [ svelte-component-docs ] | An imported Svelte component |
149+ | ` mountOptions ` | [ component options] [ svelte-mount-docs ] | Options to pass to Svelte's ` mount ` function |
150+ | ` setupOptions ` | [ ` SetupOptions ` ] ( #setup ) | Optionally wrap the component (` wrapper ` , ` wrapperProps ` ) |
151+
152+ | Result | Type | Description |
153+ | ----------- | ------------------------------------------ | -------------------------------------------------- |
154+ | ` component ` | [ component exports] [ svelte-mount-docs ] | The component's exports from ` mount ` |
155+ | ` wrapper ` | [ component exports] [ svelte-mount-docs ] | The wrapper's exports, if a ` wrapper ` was provided |
156+ | ` unmount ` | ` () => void ` | Unmount the component from the document |
157+ | ` rerender ` | ` (props: Partial<Props>) => Promise<void> ` | Update the component's props |
139158
140159### ` cleanup `
141160
0 commit comments