@testing-library/svelte 5.2.5 → 5.2.7
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/package.json +11 -7
- package/src/component-types.d.ts +30 -18
- package/types/component-types.d.ts +30 -18
- package/types/pure.d.ts +4 -4
- package/types/pure.d.ts.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@testing-library/svelte",
|
|
3
|
-
"version": "5.2.
|
|
3
|
+
"version": "5.2.7",
|
|
4
4
|
"description": "Simple and complete Svelte testing utilities that encourage good testing practices.",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"exports": {
|
|
@@ -75,7 +75,10 @@
|
|
|
75
75
|
"build": "tsc -p tsconfig.build.json && cp src/component-types.d.ts types",
|
|
76
76
|
"contributors:add": "all-contributors add",
|
|
77
77
|
"contributors:generate": "all-contributors generate",
|
|
78
|
-
"preview-release": "./scripts/preview-release"
|
|
78
|
+
"preview-release": "./scripts/preview-release",
|
|
79
|
+
"install:3": "./scripts/install-dependencies 3",
|
|
80
|
+
"install:4": "./scripts/install-dependencies 4",
|
|
81
|
+
"install:5": "./scripts/install-dependencies 5"
|
|
79
82
|
},
|
|
80
83
|
"peerDependencies": {
|
|
81
84
|
"svelte": "^3 || ^4 || ^5 || ^5.0.0-next.0",
|
|
@@ -100,9 +103,10 @@
|
|
|
100
103
|
"@testing-library/user-event": "^14.5.2",
|
|
101
104
|
"@typescript-eslint/eslint-plugin": "^8.0.0",
|
|
102
105
|
"@typescript-eslint/parser": "^8.0.0",
|
|
103
|
-
"@vitest/coverage-v8": "^2.0.2",
|
|
106
|
+
"@vitest/coverage-v8": "0.x.x || ^1.0.0 || ^2.0.2",
|
|
104
107
|
"all-contributors-cli": "^6.26.1",
|
|
105
108
|
"doctoc": "^2.2.1",
|
|
109
|
+
"esbuild": "*",
|
|
106
110
|
"eslint": "^8.57.0",
|
|
107
111
|
"eslint-config-prettier": "^9.1.0",
|
|
108
112
|
"eslint-config-standard": "^17.1.0",
|
|
@@ -112,7 +116,7 @@
|
|
|
112
116
|
"eslint-plugin-simple-import-sort": "^12.1.1",
|
|
113
117
|
"eslint-plugin-svelte": "^2.42.0",
|
|
114
118
|
"expect-type": "^1.1.0",
|
|
115
|
-
"happy-dom": "^
|
|
119
|
+
"happy-dom": "^16.3.0",
|
|
116
120
|
"jest": "^29.7.0",
|
|
117
121
|
"jest-environment-jsdom": "^29.7.0",
|
|
118
122
|
"jsdom": "^25.0.0",
|
|
@@ -120,10 +124,10 @@
|
|
|
120
124
|
"prettier": "^3.3.3",
|
|
121
125
|
"prettier-plugin-svelte": "^3.2.5",
|
|
122
126
|
"svelte": "^3 || ^4 || ^5 || ^5.0.0-next.0",
|
|
123
|
-
"svelte-check": "^4.0.4",
|
|
127
|
+
"svelte-check": "^3.0.0 || ^4.0.4",
|
|
124
128
|
"svelte-jester": "^5.0.0",
|
|
125
129
|
"typescript": "^5.5.3",
|
|
126
|
-
"vite": "^5.3.3",
|
|
127
|
-
"vitest": "^2.0.2"
|
|
130
|
+
"vite": "^4.0.0 || ^5.3.3",
|
|
131
|
+
"vitest": "0.x.x || ^1.0.0 || ^2.0.2"
|
|
128
132
|
}
|
|
129
133
|
}
|
package/src/component-types.d.ts
CHANGED
|
@@ -1,17 +1,30 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-redundant-type-constituents */
|
|
2
|
-
import type
|
|
2
|
+
import type {
|
|
3
|
+
Component as ModernComponent,
|
|
4
|
+
ComponentConstructorOptions as LegacyConstructorOptions,
|
|
5
|
+
ComponentProps,
|
|
6
|
+
EventDispatcher,
|
|
7
|
+
mount,
|
|
8
|
+
SvelteComponent as LegacyComponent,
|
|
9
|
+
SvelteComponentTyped as Svelte3LegacyComponent,
|
|
10
|
+
} from 'svelte'
|
|
3
11
|
|
|
4
|
-
type IS_MODERN_SVELTE =
|
|
12
|
+
type IS_MODERN_SVELTE = ModernComponent extends (...args: any[]) => any
|
|
5
13
|
? true
|
|
6
14
|
: false
|
|
7
15
|
|
|
16
|
+
type IS_LEGACY_SVELTE_4 =
|
|
17
|
+
EventDispatcher<any> extends (...args: any[]) => any ? true : false
|
|
18
|
+
|
|
8
19
|
/** A compiled, imported Svelte component. */
|
|
9
20
|
export type Component<
|
|
10
|
-
P extends Record<string, any
|
|
11
|
-
E extends Record<string, any
|
|
21
|
+
P extends Record<string, any> = any,
|
|
22
|
+
E extends Record<string, any> = any,
|
|
12
23
|
> = IS_MODERN_SVELTE extends true
|
|
13
|
-
?
|
|
14
|
-
:
|
|
24
|
+
? ModernComponent<P, E> | LegacyComponent<P>
|
|
25
|
+
: IS_LEGACY_SVELTE_4 extends true
|
|
26
|
+
? LegacyComponent<P>
|
|
27
|
+
: Svelte3LegacyComponent<P>
|
|
15
28
|
|
|
16
29
|
/**
|
|
17
30
|
* The type of an imported, compiled Svelte component.
|
|
@@ -19,12 +32,12 @@ export type Component<
|
|
|
19
32
|
* In Svelte 5, this distinction no longer matters.
|
|
20
33
|
* In Svelte 4, this is the Svelte component class constructor.
|
|
21
34
|
*/
|
|
22
|
-
export type ComponentType<C> =
|
|
23
|
-
? C
|
|
24
|
-
:
|
|
35
|
+
export type ComponentType<C> = C extends LegacyComponent
|
|
36
|
+
? new (...args: any[]) => C
|
|
37
|
+
: C
|
|
25
38
|
|
|
26
39
|
/** The props of a component. */
|
|
27
|
-
export type Props<C extends Component
|
|
40
|
+
export type Props<C extends Component> = ComponentProps<C>
|
|
28
41
|
|
|
29
42
|
/**
|
|
30
43
|
* The exported fields of a component.
|
|
@@ -32,18 +45,17 @@ export type Props<C extends Component<any, any>> = Svelte.ComponentProps<C>
|
|
|
32
45
|
* In Svelte 5, this is the set of variables marked as `export`'d.
|
|
33
46
|
* In Svelte 4, this is simply the instance of the component class.
|
|
34
47
|
*/
|
|
35
|
-
export type Exports<C> =
|
|
36
|
-
? C
|
|
37
|
-
: C extends Svelte.Component<any, infer E>
|
|
48
|
+
export type Exports<C> = IS_MODERN_SVELTE extends true
|
|
49
|
+
? C extends ModernComponent<any, infer E>
|
|
38
50
|
? E
|
|
39
|
-
: never
|
|
51
|
+
: C & { $set: never; $on: never; $destroy: never }
|
|
52
|
+
: C
|
|
40
53
|
|
|
41
54
|
/**
|
|
42
55
|
* Options that may be passed to `mount` when rendering the component.
|
|
43
56
|
*
|
|
44
57
|
* In Svelte 4, these are the options passed to the component constructor.
|
|
45
58
|
*/
|
|
46
|
-
export type MountOptions<C extends Component
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
: Svelte.ComponentConstructorOptions<Props<C>>
|
|
59
|
+
export type MountOptions<C extends Component> = IS_MODERN_SVELTE extends true
|
|
60
|
+
? Parameters<typeof mount<Props<C>, Exports<C>>>[1]
|
|
61
|
+
: LegacyConstructorOptions<Props<C>>
|
|
@@ -1,17 +1,30 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-redundant-type-constituents */
|
|
2
|
-
import type
|
|
2
|
+
import type {
|
|
3
|
+
Component as ModernComponent,
|
|
4
|
+
ComponentConstructorOptions as LegacyConstructorOptions,
|
|
5
|
+
ComponentProps,
|
|
6
|
+
EventDispatcher,
|
|
7
|
+
mount,
|
|
8
|
+
SvelteComponent as LegacyComponent,
|
|
9
|
+
SvelteComponentTyped as Svelte3LegacyComponent,
|
|
10
|
+
} from 'svelte'
|
|
3
11
|
|
|
4
|
-
type IS_MODERN_SVELTE =
|
|
12
|
+
type IS_MODERN_SVELTE = ModernComponent extends (...args: any[]) => any
|
|
5
13
|
? true
|
|
6
14
|
: false
|
|
7
15
|
|
|
16
|
+
type IS_LEGACY_SVELTE_4 =
|
|
17
|
+
EventDispatcher<any> extends (...args: any[]) => any ? true : false
|
|
18
|
+
|
|
8
19
|
/** A compiled, imported Svelte component. */
|
|
9
20
|
export type Component<
|
|
10
|
-
P extends Record<string, any
|
|
11
|
-
E extends Record<string, any
|
|
21
|
+
P extends Record<string, any> = any,
|
|
22
|
+
E extends Record<string, any> = any,
|
|
12
23
|
> = IS_MODERN_SVELTE extends true
|
|
13
|
-
?
|
|
14
|
-
:
|
|
24
|
+
? ModernComponent<P, E> | LegacyComponent<P>
|
|
25
|
+
: IS_LEGACY_SVELTE_4 extends true
|
|
26
|
+
? LegacyComponent<P>
|
|
27
|
+
: Svelte3LegacyComponent<P>
|
|
15
28
|
|
|
16
29
|
/**
|
|
17
30
|
* The type of an imported, compiled Svelte component.
|
|
@@ -19,12 +32,12 @@ export type Component<
|
|
|
19
32
|
* In Svelte 5, this distinction no longer matters.
|
|
20
33
|
* In Svelte 4, this is the Svelte component class constructor.
|
|
21
34
|
*/
|
|
22
|
-
export type ComponentType<C> =
|
|
23
|
-
? C
|
|
24
|
-
:
|
|
35
|
+
export type ComponentType<C> = C extends LegacyComponent
|
|
36
|
+
? new (...args: any[]) => C
|
|
37
|
+
: C
|
|
25
38
|
|
|
26
39
|
/** The props of a component. */
|
|
27
|
-
export type Props<C extends Component
|
|
40
|
+
export type Props<C extends Component> = ComponentProps<C>
|
|
28
41
|
|
|
29
42
|
/**
|
|
30
43
|
* The exported fields of a component.
|
|
@@ -32,18 +45,17 @@ export type Props<C extends Component<any, any>> = Svelte.ComponentProps<C>
|
|
|
32
45
|
* In Svelte 5, this is the set of variables marked as `export`'d.
|
|
33
46
|
* In Svelte 4, this is simply the instance of the component class.
|
|
34
47
|
*/
|
|
35
|
-
export type Exports<C> =
|
|
36
|
-
? C
|
|
37
|
-
: C extends Svelte.Component<any, infer E>
|
|
48
|
+
export type Exports<C> = IS_MODERN_SVELTE extends true
|
|
49
|
+
? C extends ModernComponent<any, infer E>
|
|
38
50
|
? E
|
|
39
|
-
: never
|
|
51
|
+
: C & { $set: never; $on: never; $destroy: never }
|
|
52
|
+
: C
|
|
40
53
|
|
|
41
54
|
/**
|
|
42
55
|
* Options that may be passed to `mount` when rendering the component.
|
|
43
56
|
*
|
|
44
57
|
* In Svelte 4, these are the options passed to the component constructor.
|
|
45
58
|
*/
|
|
46
|
-
export type MountOptions<C extends Component
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
: Svelte.ComponentConstructorOptions<Props<C>>
|
|
59
|
+
export type MountOptions<C extends Component> = IS_MODERN_SVELTE extends true
|
|
60
|
+
? Parameters<typeof mount<Props<C>, Exports<C>>>[1]
|
|
61
|
+
: LegacyConstructorOptions<Props<C>>
|
package/types/pure.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Customize how Svelte renders the component.
|
|
3
3
|
*/
|
|
4
|
-
export type SvelteComponentOptions<C extends
|
|
4
|
+
export type SvelteComponentOptions<C extends import("./component-types.js").Component> = import("./component-types.js").Props<C> | Partial<import("./component-types.js").MountOptions<C>>;
|
|
5
5
|
/**
|
|
6
6
|
* Customize how Testing Library sets up the document and binds queries.
|
|
7
7
|
*/
|
|
@@ -12,7 +12,7 @@ export type RenderOptions<Q extends import("@testing-library/dom").Queries = typ
|
|
|
12
12
|
/**
|
|
13
13
|
* The rendered component and bound testing functions.
|
|
14
14
|
*/
|
|
15
|
-
export type RenderResult<C extends
|
|
15
|
+
export type RenderResult<C extends import("./component-types.js").Component, Q extends import("@testing-library/dom").Queries = typeof import("@testing-library/dom/types/queries.js")> = {
|
|
16
16
|
container: HTMLElement;
|
|
17
17
|
baseElement: HTMLElement;
|
|
18
18
|
component: import("./component-types.js").Exports<C>;
|
|
@@ -28,7 +28,7 @@ export type FireObject = { [K in import("@testing-library/dom").EventType]: (...
|
|
|
28
28
|
* @param {() => unknown} [fn] - A function, which may be `async`, to call before flushing updates.
|
|
29
29
|
* @returns {Promise<void>}
|
|
30
30
|
*/
|
|
31
|
-
export function act(fn?: (
|
|
31
|
+
export function act(fn?: () => unknown): Promise<void>;
|
|
32
32
|
/** Unmount all components and remove elements added to `<body>`. */
|
|
33
33
|
export function cleanup(): void;
|
|
34
34
|
/**
|
|
@@ -91,5 +91,5 @@ export const fireEvent: FireFunction & FireObject;
|
|
|
91
91
|
* @param {RenderOptions<Q>} renderOptions - Customize how Testing Library sets up the document and binds queries.
|
|
92
92
|
* @returns {RenderResult<C, Q>} The rendered component and bound testing functions.
|
|
93
93
|
*/
|
|
94
|
-
export function render<C extends
|
|
94
|
+
export function render<C extends import("./component-types.js").Component, Q extends import("@testing-library/dom").Queries = typeof import("@testing-library/dom/types/queries.js")>(Component: import("./component-types.js").ComponentType<C>, options?: SvelteComponentOptions<C>, renderOptions?: RenderOptions<Q>): RenderResult<C, Q>;
|
|
95
95
|
//# sourceMappingURL=pure.d.ts.map
|
package/types/pure.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pure.d.ts","sourceRoot":"","sources":["../src/pure.js"],"names":[],"mappings":";;;mCAewD,CAAC,SAA5C,
|
|
1
|
+
{"version":3,"file":"pure.d.ts","sourceRoot":"","sources":["../src/pure.js"],"names":[],"mappings":";;;mCAewD,CAAC,SAA5C,OAAQ,sBAAsB,EAAE,SAAU,IAC1C,OAAO,sBAAsB,EAAE,KAAK,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,OAAO,sBAAsB,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC;;;;0BAMvD,CAAC,SAA3C,OAAQ,sBAAsB,EAAE,OAAQ,6DACxC;IACR,WAAW,CAAC,EAAE,WAAW,CAAA;IACzB,OAAO,CAAC,EAAE,CAAC,CAAA;CACZ;;;;yBAMoD,CAAC,SAA5C,OAAQ,sBAAsB,EAAE,SAAU,EACA,CAAC,SAA3C,OAAQ,sBAAsB,EAAE,OAAQ,6DAExC;IACR,SAAS,EAAE,WAAW,CAAA;IACtB,WAAW,EAAE,WAAW,CAAA;IACxB,SAAS,EAAE,OAAO,sBAAsB,EAAE,OAAO,CAAC,CAAC,CAAC,CAAA;IACpD,KAAK,EAAE,CAAC,EAAE,CAAC,EAAE,WAAW,GAAG,gBAAgB,KAAK,IAAI,CAAA;IACpD,QAA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