@testing-library/svelte 5.3.1 → 5.4.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 CHANGED
@@ -238,10 +238,19 @@ Thanks goes to these people ([emoji key][emojis]):
238
238
  <td align="center" valign="top" width="14.28%"><a href="http://www.benmccann.com"><img src="https://avatars.githubusercontent.com/u/322311?v=4?s=100" width="100px;" alt="Ben McCann"/><br /><sub><b>Ben McCann</b></sub></a><br /><a href="https://github.com/testing-library/svelte-testing-library/commits?author=benmccann" title="Tests">⚠️</a></td>
239
239
  <td align="center" valign="top" width="14.28%"><a href="https://johnbowser.dev/"><img src="https://avatars.githubusercontent.com/u/66637570?v=4?s=100" width="100px;" alt="John Bowser"/><br /><sub><b>John Bowser</b></sub></a><br /><a href="https://github.com/testing-library/svelte-testing-library/commits?author=jgbowser" title="Code">💻</a> <a href="https://github.com/testing-library/svelte-testing-library/commits?author=jgbowser" title="Tests">⚠️</a></td>
240
240
  <td align="center" valign="top" width="14.28%"><a href="https://github.com/ysitbon"><img src="https://avatars.githubusercontent.com/u/1370679?v=4?s=100" width="100px;" alt="Yoann"/><br /><sub><b>Yoann</b></sub></a><br /><a href="https://github.com/testing-library/svelte-testing-library/commits?author=ysitbon" title="Code">💻</a></td>
241
- <td align="center" valign="top" width="14.28%"><a href="https://techblog.babyl.ca/"><img src="https://avatars.githubusercontent.com/u/19954?v=4?s=100" width="100px;" alt="Yanick Champoux"/><br /><sub><b>Yanick Champoux</b></sub></a><br /><a href="https://github.com/testing-library/svelte-testing-library/commits?author=yanick" title="Code">💻</a></td>
241
+ <td align="center" valign="top" width="14.28%"><a href="https://techblog.babyl.ca/"><img src="https://avatars.githubusercontent.com/u/19954?v=4?s=100" width="100px;" alt="Yanick Champoux"/><br /><sub><b>Yanick Champoux</b></sub></a><br /><a href="https://github.com/testing-library/svelte-testing-library/commits?author=yanick" title="Code">💻</a> <a href="#maintenance-yanick" title="Maintenance">🚧</a></td>
242
242
  </tr>
243
243
  <tr>
244
- <td align="center" valign="top" width="14.28%"><a href="https://michael.cousins.io/"><img src="https://avatars.githubusercontent.com/u/2963448?v=4?s=100" width="100px;" alt="Michael Cousins"/><br /><sub><b>Michael Cousins</b></sub></a><br /><a href="https://github.com/testing-library/svelte-testing-library/commits?author=mcous" title="Code">💻</a></td>
244
+ <td align="center" valign="top" width="14.28%"><a href="https://michael.cousins.io/"><img src="https://avatars.githubusercontent.com/u/2963448?v=4?s=100" width="100px;" alt="Michael Cousins"/><br /><sub><b>Michael Cousins</b></sub></a><br /><a href="#ideas-mcous" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/testing-library/svelte-testing-library/commits?author=mcous" title="Tests">⚠️</a> <a href="#question-mcous" title="Answering Questions">💬</a> <a href="https://github.com/testing-library/svelte-testing-library/commits?author=mcous" title="Code">💻</a> <a href="#maintenance-mcous" title="Maintenance">🚧</a> <a href="https://github.com/testing-library/svelte-testing-library/commits?author=mcous" title="Documentation">📖</a> <a href="#example-mcous" title="Examples">💡</a></td>
245
+ <td align="center" valign="top" width="14.28%"><a href="https://dotnet.social/@webJose"><img src="https://avatars.githubusercontent.com/u/25540842?v=4?s=100" width="100px;" alt="José Pablo Ramírez Vargas"/><br /><sub><b>José Pablo Ramírez Vargas</b></sub></a><br /><a href="https://github.com/testing-library/svelte-testing-library/issues?q=author%3AwebJose" title="Bug reports">🐛</a> <a href="#question-webJose" title="Answering Questions">💬</a></td>
246
+ <td align="center" valign="top" width="14.28%"><a href="https://github.com/stefanhoelzl"><img src="https://avatars.githubusercontent.com/u/1478183?v=4?s=100" width="100px;" alt="Stefan Hoelzl"/><br /><sub><b>Stefan Hoelzl</b></sub></a><br /><a href="#ideas-stefanhoelzl" title="Ideas, Planning, & Feedback">🤔</a></td>
247
+ <td align="center" valign="top" width="14.28%"><a href="https://github.com/bradyisom"><img src="https://avatars.githubusercontent.com/u/593515?v=4?s=100" width="100px;" alt="Brady Isom"/><br /><sub><b>Brady Isom</b></sub></a><br /><a href="https://github.com/testing-library/svelte-testing-library/issues?q=author%3Abradyisom" title="Bug reports">🐛</a> <a href="#example-bradyisom" title="Examples">💡</a></td>
248
+ <td align="center" valign="top" width="14.28%"><a href="http://k776.tumblr.com/"><img src="https://avatars.githubusercontent.com/u/16620?v=4?s=100" width="100px;" alt="Kieran Pilkington"/><br /><sub><b>Kieran Pilkington</b></sub></a><br /><a href="https://github.com/testing-library/svelte-testing-library/issues?q=author%3AKieranP" title="Bug reports">🐛</a> <a href="#example-KieranP" title="Examples">💡</a></td>
249
+ <td align="center" valign="top" width="14.28%"><a href="https://github.com/cezaryszymanski"><img src="https://avatars.githubusercontent.com/u/104898426?v=4?s=100" width="100px;" alt="Cezary Szymański"/><br /><sub><b>Cezary Szymański</b></sub></a><br /><a href="https://github.com/testing-library/svelte-testing-library/issues?q=author%3Acezaryszymanski" title="Bug reports">🐛</a></td>
250
+ <td align="center" valign="top" width="14.28%"><a href="https://github.com/neo-noire"><img src="https://avatars.githubusercontent.com/u/111647919?v=4?s=100" width="100px;" alt="Mykola"/><br /><sub><b>Mykola</b></sub></a><br /><a href="#example-neo-noire" title="Examples">💡</a></td>
251
+ </tr>
252
+ <tr>
253
+ <td align="center" valign="top" width="14.28%"><a href="https://github.com/axel7083"><img src="https://avatars.githubusercontent.com/u/42176370?v=4?s=100" width="100px;" alt="axel7083"/><br /><sub><b>axel7083</b></sub></a><br /><a href="#ideas-axel7083" title="Ideas, Planning, & Feedback">🤔</a></td>
245
254
  </tr>
246
255
  </tbody>
247
256
  </table>
package/dist/pure.d.ts CHANGED
@@ -7,16 +7,17 @@ export type SvelteComponentOptions<C extends import("@testing-library/svelte-cor
7
7
  /**
8
8
  * Customize how Testing Library sets up the document and binds queries.
9
9
  */
10
- export type RenderOptions<Q extends DomTestingLibrary.Queries = typeof DomTestingLibrary.queries> = import("@testing-library/svelte-core/types").SetupOptions & {
10
+ export type RenderOptions<Q extends DomTestingLibrary.Queries = typeof DomTestingLibrary.queries, W extends import("@testing-library/svelte-core/types").Component = never> = import("@testing-library/svelte-core/types").SetupOptions<W> & {
11
11
  queries?: Q;
12
12
  };
13
13
  /**
14
14
  * The rendered component and bound testing functions.
15
15
  */
16
- export type RenderResult<C extends import("@testing-library/svelte-core/types").Component, Q extends DomTestingLibrary.Queries = typeof DomTestingLibrary.queries> = {
16
+ export type RenderResult<C extends import("@testing-library/svelte-core/types").Component, Q extends DomTestingLibrary.Queries = typeof DomTestingLibrary.queries, W extends import("@testing-library/svelte-core/types").Component = never> = {
17
17
  container: HTMLElement;
18
18
  baseElement: HTMLElement;
19
19
  component: import("@testing-library/svelte-core/types").Exports<C>;
20
+ wrapper: import("@testing-library/svelte-core/types").Exports<W>;
20
21
  debug: (el?: HTMLElement | DocumentFragment) => void;
21
22
  rerender: import("@testing-library/svelte-core/types").Rerender<C>;
22
23
  unmount: () => void;
@@ -60,18 +61,21 @@ export const fireEvent: FireFunction & FireObject;
60
61
  * Customize how Testing Library sets up the document and binds queries.
61
62
  *
62
63
  * @template {DomTestingLibrary.Queries} [Q=typeof DomTestingLibrary.queries]
63
- * @typedef {import('@testing-library/svelte-core/types').SetupOptions & { queries?: Q }} RenderOptions
64
+ * @template {import('@testing-library/svelte-core/types').Component} [W=never]
65
+ * @typedef {import('@testing-library/svelte-core/types').SetupOptions<W> & { queries?: Q }} RenderOptions
64
66
  */
65
67
  /**
66
68
  * The rendered component and bound testing functions.
67
69
  *
68
70
  * @template {import('@testing-library/svelte-core/types').Component} C
69
71
  * @template {DomTestingLibrary.Queries} [Q=typeof DomTestingLibrary.queries]
72
+ * @template {import('@testing-library/svelte-core/types').Component} [W=never]
70
73
  *
71
74
  * @typedef {{
72
75
  * container: HTMLElement
73
76
  * baseElement: HTMLElement
74
77
  * component: import('@testing-library/svelte-core/types').Exports<C>
78
+ * wrapper: import('@testing-library/svelte-core/types').Exports<W>
75
79
  * debug: (el?: HTMLElement | DocumentFragment) => void
76
80
  * rerender: import('@testing-library/svelte-core/types').Rerender<C>
77
81
  * unmount: () => void
@@ -84,13 +88,14 @@ export const fireEvent: FireFunction & FireObject;
84
88
  *
85
89
  * @template {import('@testing-library/svelte-core/types').Component} C
86
90
  * @template {DomTestingLibrary.Queries} [Q=typeof DomTestingLibrary.queries]
91
+ * @template {import('@testing-library/svelte-core/types').Component} [W=never]
87
92
  *
88
93
  * @param {import('@testing-library/svelte-core/types').ComponentImport<C>} Component - The component to render.
89
94
  * @param {import('@testing-library/svelte-core/types').ComponentOptions<C>} options - Customize how Svelte renders the component.
90
- * @param {RenderOptions<Q>} renderOptions - Customize how Testing Library sets up the document and binds queries.
91
- * @returns {RenderResult<C, Q>} The rendered component and bound testing functions.
95
+ * @param {RenderOptions<Q, W>} renderOptions - Customize how Testing Library sets up the document and binds queries.
96
+ * @returns {RenderResult<C, Q, W>} The rendered component and bound testing functions.
92
97
  */
93
- export function render<C extends import("@testing-library/svelte-core/types").Component, Q extends DomTestingLibrary.Queries = typeof DomTestingLibrary.queries>(Component: import("@testing-library/svelte-core/types").ComponentImport<C>, options?: import("@testing-library/svelte-core/types").ComponentOptions<C>, renderOptions?: RenderOptions<Q>): RenderResult<C, Q>;
98
+ export function render<C extends import("@testing-library/svelte-core/types").Component, Q extends DomTestingLibrary.Queries = typeof DomTestingLibrary.queries, W extends import("@testing-library/svelte-core/types").Component = never>(Component: import("@testing-library/svelte-core/types").ComponentImport<C>, options?: import("@testing-library/svelte-core/types").ComponentOptions<C>, renderOptions?: RenderOptions<Q, W>): RenderResult<C, Q, W>;
94
99
  /**
95
100
  * Configure `@testing-library/dom` for usage with Svelte.
96
101
  *
@@ -1 +1 @@
1
- {"version":3,"file":"pure.d.ts","sourceRoot":"","sources":["../src/pure.js"],"names":[],"mappings":";;;;;mCAOsE,CAAC,SAA1D,OAAQ,oCAAoC,EAAE,SAAU,IACxD,OAAO,oCAAoC,EAAE,gBAAgB,CAAC,CAAC,CAAC;;;;0BAMnC,CAAC,SAA7B,iBAAiB,CAAC,OAAQ,uCAC3B,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C;mCA1FkC,sBAAsB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@testing-library/svelte",
3
- "version": "5.3.1",
3
+ "version": "5.4.0",
4
4
  "description": "Simple and complete Svelte testing utilities that encourage good testing practices.",
5
5
  "main": "src/index.js",
6
6
  "exports": {
@@ -71,7 +71,7 @@
71
71
  },
72
72
  "dependencies": {
73
73
  "@testing-library/dom": "9.x.x || 10.x.x",
74
- "@testing-library/svelte-core": "1.0.0"
74
+ "@testing-library/svelte-core": "1.1.0"
75
75
  },
76
76
  "publishConfig": {
77
77
  "access": "public",
package/src/pure.js CHANGED
@@ -13,7 +13,8 @@ import * as Svelte from 'svelte'
13
13
  * Customize how Testing Library sets up the document and binds queries.
14
14
  *
15
15
  * @template {DomTestingLibrary.Queries} [Q=typeof DomTestingLibrary.queries]
16
- * @typedef {import('@testing-library/svelte-core/types').SetupOptions & { queries?: Q }} RenderOptions
16
+ * @template {import('@testing-library/svelte-core/types').Component} [W=never]
17
+ * @typedef {import('@testing-library/svelte-core/types').SetupOptions<W> & { queries?: Q }} RenderOptions
17
18
  */
18
19
 
19
20
  /**
@@ -21,11 +22,13 @@ import * as Svelte from 'svelte'
21
22
  *
22
23
  * @template {import('@testing-library/svelte-core/types').Component} C
23
24
  * @template {DomTestingLibrary.Queries} [Q=typeof DomTestingLibrary.queries]
25
+ * @template {import('@testing-library/svelte-core/types').Component} [W=never]
24
26
  *
25
27
  * @typedef {{
26
28
  * container: HTMLElement
27
29
  * baseElement: HTMLElement
28
30
  * component: import('@testing-library/svelte-core/types').Exports<C>
31
+ * wrapper: import('@testing-library/svelte-core/types').Exports<W>
29
32
  * debug: (el?: HTMLElement | DocumentFragment) => void
30
33
  * rerender: import('@testing-library/svelte-core/types').Rerender<C>
31
34
  * unmount: () => void
@@ -39,18 +42,16 @@ import * as Svelte from 'svelte'
39
42
  *
40
43
  * @template {import('@testing-library/svelte-core/types').Component} C
41
44
  * @template {DomTestingLibrary.Queries} [Q=typeof DomTestingLibrary.queries]
45
+ * @template {import('@testing-library/svelte-core/types').Component} [W=never]
42
46
  *
43
47
  * @param {import('@testing-library/svelte-core/types').ComponentImport<C>} Component - The component to render.
44
48
  * @param {import('@testing-library/svelte-core/types').ComponentOptions<C>} options - Customize how Svelte renders the component.
45
- * @param {RenderOptions<Q>} renderOptions - Customize how Testing Library sets up the document and binds queries.
46
- * @returns {RenderResult<C, Q>} The rendered component and bound testing functions.
49
+ * @param {RenderOptions<Q, W>} renderOptions - Customize how Testing Library sets up the document and binds queries.
50
+ * @returns {RenderResult<C, Q, W>} The rendered component and bound testing functions.
47
51
  */
48
52
  const render = (Component, options = {}, renderOptions = {}) => {
49
- const { baseElement, container, component, unmount, rerender } = Core.render(
50
- Component,
51
- options,
52
- renderOptions
53
- )
53
+ const { baseElement, container, component, wrapper, unmount, rerender } =
54
+ Core.render(Component, options, renderOptions)
54
55
 
55
56
  const queries = DomTestingLibrary.getQueriesForElement(
56
57
  baseElement,
@@ -61,6 +62,7 @@ const render = (Component, options = {}, renderOptions = {}) => {
61
62
  baseElement,
62
63
  container,
63
64
  component,
65
+ wrapper,
64
66
  rerender,
65
67
  unmount,
66
68
  debug: (el = baseElement) => console.log(DomTestingLibrary.prettyDOM(el)),
package/src/vitest.js CHANGED
@@ -1,11 +1,12 @@
1
1
  import { act, cleanup, setup } from '@testing-library/svelte'
2
2
  import { beforeEach } from 'vitest'
3
3
 
4
+ const afterEach = async () => {
5
+ await act()
6
+ cleanup()
7
+ }
8
+
4
9
  beforeEach(() => {
5
10
  setup()
6
-
7
- return async () => {
8
- await act()
9
- cleanup()
10
- }
11
+ return afterEach
11
12
  })