@testing-library/svelte 3.0.3 → 3.1.2
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 +18 -14
- package/dist/pure.js +20 -17
- package/package.json +13 -12
- package/types/index.d.ts +25 -7
- package/CHANGELOG.md +0 -5
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
height="80"
|
|
7
7
|
width="80"
|
|
8
8
|
alt="chipmunk"
|
|
9
|
-
src="https://raw.githubusercontent.com/testing-library/svelte-testing-library/
|
|
9
|
+
src="https://raw.githubusercontent.com/testing-library/svelte-testing-library/main/other/chipmunk.png"
|
|
10
10
|
/>
|
|
11
11
|
</a>
|
|
12
12
|
|
|
@@ -121,22 +121,26 @@ Thanks goes to these people ([emoji key][emojis]):
|
|
|
121
121
|
<!-- markdownlint-disable -->
|
|
122
122
|
<table>
|
|
123
123
|
<tr>
|
|
124
|
-
<td align="center"><a href="https://github.com/benmonro"><img src="https://avatars3.githubusercontent.com/u/399236?v=4" width="100px;" alt=""/><br /><sub><b>Ben Monro</b></sub></a><br /><a href="https://github.com/testing-library/svelte-testing-library/commits?author=benmonro" title="Code">💻</a> <a href="https://github.com/testing-library/svelte-testing-library/commits?author=benmonro" title="Tests">⚠️</a> <a href="#ideas-benmonro" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/testing-library/svelte-testing-library/commits?author=benmonro" title="Documentation">📖</a></td>
|
|
125
|
-
<td align="center"><a href="https://twitter.com/EmilTholin"><img src="https://avatars0.githubusercontent.com/u/11573167?v=4" width="100px;" alt=""/><br /><sub><b>Emil Tholin</b></sub></a><br /><a href="https://github.com/testing-library/svelte-testing-library/commits?author=EmilTholin" title="Code">💻</a> <a href="https://github.com/testing-library/svelte-testing-library/commits?author=EmilTholin" title="Tests">⚠️</a> <a href="#ideas-EmilTholin" title="Ideas, Planning, & Feedback">🤔</a></td>
|
|
126
|
-
<td align="center"><a href="https://medium.com/@oieduardorabelo"><img src="https://avatars1.githubusercontent.com/u/829902?v=4" width="100px;" alt=""/><br /><sub><b>Eduardo Rabelo</b></sub></a><br /><a href="https://github.com/testing-library/svelte-testing-library/commits?author=oieduardorabelo" title="Tests">⚠️</a> <a href="https://github.com/testing-library/svelte-testing-library/commits?author=oieduardorabelo" title="Code">💻</a> <a href="https://github.com/testing-library/svelte-testing-library/commits?author=oieduardorabelo" title="Documentation">📖</a> <a href="#example-oieduardorabelo" title="Examples">💡</a></td>
|
|
127
|
-
<td align="center"><a href="http://timdeschryver.dev"><img src="https://avatars1.githubusercontent.com/u/28659384?v=4" width="100px;" alt=""/><br /><sub><b>Tim Deschryver</b></sub></a><br /><a href="https://github.com/testing-library/svelte-testing-library/commits?author=timdeschryver" title="Documentation">📖</a></td>
|
|
128
|
-
<td align="center"><a href="http://www.ematipico.com"><img src="https://avatars3.githubusercontent.com/u/602478?v=4" width="100px;" alt=""/><br /><sub><b>Emanuele</b></sub></a><br /><a href="https://github.com/testing-library/svelte-testing-library/commits?author=ematipico" title="Code">💻</a> <a href="https://github.com/testing-library/svelte-testing-library/commits?author=ematipico" title="Tests">⚠️</a> <a href="https://github.com/testing-library/svelte-testing-library/commits?author=ematipico" title="Documentation">📖</a></td>
|
|
129
|
-
<td align="center"><a href="https://github.com/pngwn"><img src="https://avatars1.githubusercontent.com/u/12937446?v=4" width="100px;" alt=""/><br /><sub><b>pngwn</b></sub></a><br /><a href="https://github.com/testing-library/svelte-testing-library/commits?author=pngwn" title="Code">💻</a> <a href="https://github.com/testing-library/svelte-testing-library/commits?author=pngwn" title="Tests">⚠️</a></td>
|
|
130
|
-
<td align="center"><a href="https://twitter.com/sebsilbermann"><img src="https://avatars3.githubusercontent.com/u/12292047?v=4" width="100px;" alt=""/><br /><sub><b>Sebastian Silbermann</b></sub></a><br /><a href="https://github.com/testing-library/svelte-testing-library/commits?author=eps1lon" title="Code">💻</a></td>
|
|
124
|
+
<td align="center"><a href="https://github.com/benmonro"><img src="https://avatars3.githubusercontent.com/u/399236?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Ben Monro</b></sub></a><br /><a href="https://github.com/testing-library/svelte-testing-library/commits?author=benmonro" title="Code">💻</a> <a href="https://github.com/testing-library/svelte-testing-library/commits?author=benmonro" title="Tests">⚠️</a> <a href="#ideas-benmonro" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/testing-library/svelte-testing-library/commits?author=benmonro" title="Documentation">📖</a></td>
|
|
125
|
+
<td align="center"><a href="https://twitter.com/EmilTholin"><img src="https://avatars0.githubusercontent.com/u/11573167?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Emil Tholin</b></sub></a><br /><a href="https://github.com/testing-library/svelte-testing-library/commits?author=EmilTholin" title="Code">💻</a> <a href="https://github.com/testing-library/svelte-testing-library/commits?author=EmilTholin" title="Tests">⚠️</a> <a href="#ideas-EmilTholin" title="Ideas, Planning, & Feedback">🤔</a></td>
|
|
126
|
+
<td align="center"><a href="https://medium.com/@oieduardorabelo"><img src="https://avatars1.githubusercontent.com/u/829902?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Eduardo Rabelo</b></sub></a><br /><a href="https://github.com/testing-library/svelte-testing-library/commits?author=oieduardorabelo" title="Tests">⚠️</a> <a href="https://github.com/testing-library/svelte-testing-library/commits?author=oieduardorabelo" title="Code">💻</a> <a href="https://github.com/testing-library/svelte-testing-library/commits?author=oieduardorabelo" title="Documentation">📖</a> <a href="#example-oieduardorabelo" title="Examples">💡</a></td>
|
|
127
|
+
<td align="center"><a href="http://timdeschryver.dev"><img src="https://avatars1.githubusercontent.com/u/28659384?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Tim Deschryver</b></sub></a><br /><a href="https://github.com/testing-library/svelte-testing-library/commits?author=timdeschryver" title="Documentation">📖</a></td>
|
|
128
|
+
<td align="center"><a href="http://www.ematipico.com"><img src="https://avatars3.githubusercontent.com/u/602478?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Emanuele</b></sub></a><br /><a href="https://github.com/testing-library/svelte-testing-library/commits?author=ematipico" title="Code">💻</a> <a href="https://github.com/testing-library/svelte-testing-library/commits?author=ematipico" title="Tests">⚠️</a> <a href="https://github.com/testing-library/svelte-testing-library/commits?author=ematipico" title="Documentation">📖</a></td>
|
|
129
|
+
<td align="center"><a href="https://github.com/pngwn"><img src="https://avatars1.githubusercontent.com/u/12937446?v=4?s=100" width="100px;" alt=""/><br /><sub><b>pngwn</b></sub></a><br /><a href="https://github.com/testing-library/svelte-testing-library/commits?author=pngwn" title="Code">💻</a> <a href="https://github.com/testing-library/svelte-testing-library/commits?author=pngwn" title="Tests">⚠️</a></td>
|
|
130
|
+
<td align="center"><a href="https://twitter.com/sebsilbermann"><img src="https://avatars3.githubusercontent.com/u/12292047?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Sebastian Silbermann</b></sub></a><br /><a href="https://github.com/testing-library/svelte-testing-library/commits?author=eps1lon" title="Code">💻</a></td>
|
|
131
131
|
</tr>
|
|
132
132
|
<tr>
|
|
133
|
-
<td align="center"><a href="https://github.com/mihar-22"><img src="https://avatars3.githubusercontent.com/u/14304599?s=460&v=4" width="100px;" alt=""/><br /><sub><b>Rahim Alwer</b></sub></a><br /><a href="https://github.com/testing-library/svelte-testing-library/commits?author=mihar-22" title="Code">💻</a> <a href="https://github.com/testing-library/svelte-testing-library/commits?author=mihar-22" title="Documentation">📖</a> <a href="https://github.com/testing-library/svelte-testing-library/commits?author=mihar-22" title="Tests">⚠️</a></td>
|
|
134
|
-
<td align="center"><a href="https://github.com/MirrorBytes"><img src="https://avatars3.githubusercontent.com/u/22119469?v=4" width="100px;" alt=""/><br /><sub><b>Bob</b></sub></a><br /><a href="https://github.com/testing-library/svelte-testing-library/issues?q=author%3AMirrorBytes" title="Bug reports">🐛</a> <a href="https://github.com/testing-library/svelte-testing-library/commits?author=MirrorBytes" title="Code">💻</a></td>
|
|
133
|
+
<td align="center"><a href="https://github.com/mihar-22"><img src="https://avatars3.githubusercontent.com/u/14304599?s=460&v=4?s=100" width="100px;" alt=""/><br /><sub><b>Rahim Alwer</b></sub></a><br /><a href="https://github.com/testing-library/svelte-testing-library/commits?author=mihar-22" title="Code">💻</a> <a href="https://github.com/testing-library/svelte-testing-library/commits?author=mihar-22" title="Documentation">📖</a> <a href="https://github.com/testing-library/svelte-testing-library/commits?author=mihar-22" title="Tests">⚠️</a> <a href="https://github.com/testing-library/svelte-testing-library/pulls?q=is%3Apr+reviewed-by%3Amihar-22" title="Reviewed Pull Requests">👀</a></td>
|
|
134
|
+
<td align="center"><a href="https://github.com/MirrorBytes"><img src="https://avatars3.githubusercontent.com/u/22119469?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Bob</b></sub></a><br /><a href="https://github.com/testing-library/svelte-testing-library/issues?q=author%3AMirrorBytes" title="Bug reports">🐛</a> <a href="https://github.com/testing-library/svelte-testing-library/commits?author=MirrorBytes" title="Code">💻</a></td>
|
|
135
|
+
<td align="center"><a href="https://github.com/ronmerkin"><img src="https://avatars.githubusercontent.com/u/17492527?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Ron Merkin</b></sub></a><br /><a href="https://github.com/testing-library/svelte-testing-library/commits?author=ronmerkin" title="Code">💻</a></td>
|
|
136
|
+
<td align="center"><a href="http://www.benmccann.com"><img src="https://avatars.githubusercontent.com/u/322311?v=4?s=100" width="100px;" alt=""/><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>
|
|
137
|
+
<td align="center"><a href="https://johnbowser.dev/"><img src="https://avatars.githubusercontent.com/u/66637570?v=4?s=100" width="100px;" alt=""/><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>
|
|
135
138
|
</tr>
|
|
136
139
|
</table>
|
|
137
140
|
|
|
138
|
-
<!-- markdownlint-
|
|
141
|
+
<!-- markdownlint-restore -->
|
|
139
142
|
<!-- prettier-ignore-end -->
|
|
143
|
+
|
|
140
144
|
<!-- ALL-CONTRIBUTORS-LIST:END -->
|
|
141
145
|
|
|
142
146
|
This project follows the [all-contributors][all-contributors] specification.
|
|
@@ -159,14 +163,14 @@ Contributions of any kind welcome!
|
|
|
159
163
|
[downloads-badge]: https://img.shields.io/npm/dm/@testing-library/svelte.svg?style=flat-square
|
|
160
164
|
[npmtrends]: http://www.npmtrends.com/@testing-library/svelte
|
|
161
165
|
[discord-badge]: https://img.shields.io/discord/723559267868737556.svg?color=7389D8&labelColor=6A7EC2&logo=discord&logoColor=ffffff&style=flat-square
|
|
162
|
-
[discord]: https://discord.gg/
|
|
166
|
+
[discord]: https://discord.gg/testing-library
|
|
163
167
|
[license-badge]: https://img.shields.io/github/license/testing-library/svelte-testing-library?color=b
|
|
164
|
-
[license]: https://github.com/testing-library/svelte-testing-library/blob/
|
|
168
|
+
[license]: https://github.com/testing-library/svelte-testing-library/blob/main/LICENSE
|
|
165
169
|
[prs-badge]: https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square
|
|
166
170
|
[prs]: http://makeapullrequest.com
|
|
167
171
|
[donate-badge]: https://img.shields.io/badge/$-support-green.svg?style=flat-square
|
|
168
172
|
[coc-badge]: https://img.shields.io/badge/code%20of-conduct-ff69b4.svg?style=flat-square
|
|
169
|
-
[coc]: https://github.com/testing-library/svelte-testing-library/blob/
|
|
173
|
+
[coc]: https://github.com/testing-library/svelte-testing-library/blob/main/CODE_OF_CONDUCT.md
|
|
170
174
|
[github-watch-badge]: https://img.shields.io/github/watchers/testing-library/svelte-testing-library.svg?style=social
|
|
171
175
|
[github-watch]: https://github.com/testing-library/svelte-testing-library/watchers
|
|
172
176
|
[github-star-badge]: https://img.shields.io/github/stars/testing-library/svelte-testing-library.svg?style=social
|
package/dist/pure.js
CHANGED
|
@@ -9,7 +9,7 @@ var _exportNames = {
|
|
|
9
9
|
fireEvent: true,
|
|
10
10
|
act: true
|
|
11
11
|
};
|
|
12
|
-
exports.
|
|
12
|
+
exports.render = exports.fireEvent = exports.cleanup = exports.act = void 0;
|
|
13
13
|
|
|
14
14
|
var _dom = require("@testing-library/dom");
|
|
15
15
|
|
|
@@ -27,9 +27,11 @@ Object.keys(_dom).forEach(function (key) {
|
|
|
27
27
|
|
|
28
28
|
var _svelte = require("svelte");
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
const _excluded = ["target"];
|
|
31
31
|
|
|
32
|
-
function
|
|
32
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
33
|
+
|
|
34
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
33
35
|
|
|
34
36
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
35
37
|
|
|
@@ -39,7 +41,7 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
|
|
|
39
41
|
|
|
40
42
|
const containerCache = new Map();
|
|
41
43
|
const componentCache = new Set();
|
|
42
|
-
const
|
|
44
|
+
const svelteComponentOptions = ['anchor', 'props', 'hydrate', 'intro', 'context'];
|
|
43
45
|
|
|
44
46
|
const render = (Component, _ref = {}, {
|
|
45
47
|
container,
|
|
@@ -48,23 +50,23 @@ const render = (Component, _ref = {}, {
|
|
|
48
50
|
let {
|
|
49
51
|
target
|
|
50
52
|
} = _ref,
|
|
51
|
-
options = _objectWithoutProperties(_ref,
|
|
53
|
+
options = _objectWithoutProperties(_ref, _excluded);
|
|
52
54
|
|
|
53
55
|
container = container || document.body;
|
|
54
56
|
target = target || container.appendChild(document.createElement('div'));
|
|
55
57
|
const ComponentConstructor = Component.default || Component;
|
|
56
58
|
|
|
57
59
|
const checkProps = options => {
|
|
58
|
-
const isProps = !Object.keys(options).some(option =>
|
|
60
|
+
const isProps = !Object.keys(options).some(option => svelteComponentOptions.includes(option)); // Check if any props and Svelte options were accidentally mixed.
|
|
59
61
|
|
|
60
62
|
if (!isProps) {
|
|
61
|
-
const unrecognizedOptions = Object.keys(options).filter(option => !
|
|
63
|
+
const unrecognizedOptions = Object.keys(options).filter(option => !svelteComponentOptions.includes(option));
|
|
62
64
|
|
|
63
65
|
if (unrecognizedOptions.length > 0) {
|
|
64
66
|
throw Error(`
|
|
65
|
-
Unknown options were found [${unrecognizedOptions}]. This might happen if you've mixed
|
|
66
|
-
passing in props with Svelte options into the render function. Valid Svelte options
|
|
67
|
-
are [${
|
|
67
|
+
Unknown options were found [${unrecognizedOptions}]. This might happen if you've mixed
|
|
68
|
+
passing in props with Svelte options into the render function. Valid Svelte options
|
|
69
|
+
are [${svelteComponentOptions}]. You can either change the prop names, or pass in your
|
|
68
70
|
props for that component via the \`props\` option.\n\n
|
|
69
71
|
Eg: const { /** Results **/ } = render(MyComponent, { props: { /** props here **/ } })\n\n
|
|
70
72
|
`);
|
|
@@ -78,7 +80,7 @@ const render = (Component, _ref = {}, {
|
|
|
78
80
|
};
|
|
79
81
|
};
|
|
80
82
|
|
|
81
|
-
|
|
83
|
+
let component = new ComponentConstructor(_objectSpread({
|
|
82
84
|
target
|
|
83
85
|
}, checkProps(options)));
|
|
84
86
|
containerCache.set(container, {
|
|
@@ -96,16 +98,16 @@ const render = (Component, _ref = {}, {
|
|
|
96
98
|
rerender: options => {
|
|
97
99
|
if (componentCache.has(component)) component.$destroy(); // eslint-disable-next-line no-new
|
|
98
100
|
|
|
99
|
-
|
|
101
|
+
component = new ComponentConstructor(_objectSpread({
|
|
100
102
|
target
|
|
101
103
|
}, checkProps(options)));
|
|
102
104
|
containerCache.set(container, {
|
|
103
105
|
target,
|
|
104
|
-
|
|
106
|
+
component
|
|
105
107
|
});
|
|
106
|
-
componentCache.add(
|
|
107
|
-
|
|
108
|
-
componentCache.delete(
|
|
108
|
+
componentCache.add(component);
|
|
109
|
+
component.$$.on_destroy.push(() => {
|
|
110
|
+
componentCache.delete(component);
|
|
109
111
|
});
|
|
110
112
|
},
|
|
111
113
|
unmount: () => {
|
|
@@ -162,4 +164,5 @@ Object.keys(_dom.fireEvent).forEach(key => {
|
|
|
162
164
|
await (0, _svelte.tick)();
|
|
163
165
|
return event;
|
|
164
166
|
};
|
|
165
|
-
});
|
|
167
|
+
});
|
|
168
|
+
/* eslint-disable import/export */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@testing-library/svelte",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.1.2",
|
|
4
4
|
"description": "Simple and complete Svelte testing utilities that encourage good testing practices.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "types/index.d.ts",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"url": "https://github.com/testing-library/svelte-testing-library/issues"
|
|
15
15
|
},
|
|
16
16
|
"engines": {
|
|
17
|
-
"node": ">=
|
|
17
|
+
"node": ">= 10"
|
|
18
18
|
},
|
|
19
19
|
"keywords": [
|
|
20
20
|
"testing",
|
|
@@ -51,35 +51,35 @@
|
|
|
51
51
|
"svelte": "3.x"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@testing-library/dom": "^
|
|
54
|
+
"@testing-library/dom": "^8.1.0"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@babel/cli": "^7.6.2",
|
|
58
58
|
"@babel/core": "^7.6.2",
|
|
59
59
|
"@babel/plugin-transform-modules-commonjs": "^7.6.0",
|
|
60
60
|
"@babel/preset-env": "^7.6.2",
|
|
61
|
-
"@commitlint/cli": "^
|
|
62
|
-
"@commitlint/config-conventional": "^
|
|
61
|
+
"@commitlint/cli": "^13.1.0",
|
|
62
|
+
"@commitlint/config-conventional": "^13.1.0",
|
|
63
63
|
"@testing-library/jest-dom": "^5.0.2",
|
|
64
|
-
"@types/jest": "^
|
|
64
|
+
"@types/jest": "^27.0.0",
|
|
65
65
|
"all-contributors-cli": "^6.9.0",
|
|
66
66
|
"babel-eslint": "^10.0.3",
|
|
67
|
-
"babel-jest": "^
|
|
67
|
+
"babel-jest": "^27.0.6",
|
|
68
68
|
"doctoc": "^2.0.0",
|
|
69
69
|
"eslint": "^7.2.0",
|
|
70
70
|
"eslint-config-standard": "^16.0.0",
|
|
71
71
|
"eslint-plugin-import": "^2.18.2",
|
|
72
72
|
"eslint-plugin-node": "^11.0.0",
|
|
73
|
-
"eslint-plugin-promise": "^
|
|
73
|
+
"eslint-plugin-promise": "^5.1.0",
|
|
74
74
|
"eslint-plugin-simple-import-sort": "^7.0.0",
|
|
75
75
|
"eslint-plugin-svelte3": "^3.0.0",
|
|
76
|
-
"husky": "^
|
|
77
|
-
"jest": "^
|
|
78
|
-
"lint-staged": "^
|
|
76
|
+
"husky": "^7.0.1",
|
|
77
|
+
"jest": "^27.0.0",
|
|
78
|
+
"lint-staged": "^11.1.1",
|
|
79
79
|
"npm-run-all": "^4.1.5",
|
|
80
80
|
"prettier": "^2.0.1",
|
|
81
81
|
"svelte": "^3.0.0",
|
|
82
|
-
"svelte-jester": "^1.
|
|
82
|
+
"svelte-jester": "^2.1.4"
|
|
83
83
|
},
|
|
84
84
|
"husky": {
|
|
85
85
|
"hooks": {
|
|
@@ -118,6 +118,7 @@
|
|
|
118
118
|
"setupFilesAfterEnv": [
|
|
119
119
|
"@testing-library/jest-dom/extend-expect"
|
|
120
120
|
],
|
|
121
|
+
"testEnvironment": "jsdom",
|
|
121
122
|
"transform": {
|
|
122
123
|
"^.+\\.js$": "babel-jest",
|
|
123
124
|
"^.+\\.svelte$": "svelte-jester",
|
package/types/index.d.ts
CHANGED
|
@@ -3,11 +3,18 @@
|
|
|
3
3
|
// Definitions by: Rahim Alwer <https://github.com/mihar-22>
|
|
4
4
|
|
|
5
5
|
import {queries, Queries, BoundFunction, EventType} from '@testing-library/dom'
|
|
6
|
-
import {
|
|
6
|
+
import { SvelteComponentTyped } from 'svelte/types/runtime'
|
|
7
7
|
|
|
8
8
|
export * from '@testing-library/dom'
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
export interface SvelteComponentOptions<P extends Record<string, any> = any> {
|
|
11
|
+
target?: HTMLElement
|
|
12
|
+
anchor?: string
|
|
13
|
+
props?: P
|
|
14
|
+
context?: any
|
|
15
|
+
hydrate?: boolean
|
|
16
|
+
intro?: boolean
|
|
17
|
+
}
|
|
11
18
|
|
|
12
19
|
type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>
|
|
13
20
|
|
|
@@ -15,30 +22,41 @@ type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>
|
|
|
15
22
|
* Render a Component into the Document.
|
|
16
23
|
*/
|
|
17
24
|
export type RenderResult<Q extends Queries = typeof queries> = {
|
|
18
|
-
container:
|
|
25
|
+
container: Element
|
|
19
26
|
component: SvelteComponent
|
|
20
|
-
|
|
27
|
+
component: SvelteComponentTyped
|
|
28
|
+
debug: (el?: Element | DocumentFragment) => void
|
|
21
29
|
rerender: (options: SvelteComponentOptions) => void
|
|
22
30
|
unmount: () => void
|
|
23
31
|
} & { [P in keyof Q]: BoundFunction<Q[P]> }
|
|
24
32
|
|
|
25
33
|
export interface RenderOptions<Q extends Queries = typeof queries> {
|
|
26
|
-
container?:
|
|
34
|
+
container?: Element
|
|
27
35
|
queries?: Q
|
|
28
36
|
}
|
|
29
37
|
|
|
30
38
|
export function render(
|
|
31
|
-
component:
|
|
39
|
+
component: SvelteComponentTyped,
|
|
32
40
|
componentOptions?: SvelteComponentOptions,
|
|
33
41
|
renderOptions?: Omit<RenderOptions, 'queries'>
|
|
34
42
|
): RenderResult
|
|
35
43
|
|
|
36
44
|
export function render<Q extends Queries>(
|
|
37
|
-
component:
|
|
45
|
+
component: SvelteComponentTyped,
|
|
38
46
|
componentOptions?: SvelteComponentOptions,
|
|
39
47
|
renderOptions?: RenderOptions<Q>,
|
|
40
48
|
): RenderResult<Q>
|
|
41
49
|
|
|
50
|
+
export function render<
|
|
51
|
+
P extends Record<string, any> = any,
|
|
52
|
+
E extends Record<string, any> = any,
|
|
53
|
+
S extends Record<string, any> = any
|
|
54
|
+
>(
|
|
55
|
+
component: SvelteComponentTyped<P, E, S>,
|
|
56
|
+
componentOptions?: SvelteComponentOptions<P>,
|
|
57
|
+
renderOptions?: Omit<RenderOptions, "queries">
|
|
58
|
+
): RenderResult;
|
|
59
|
+
|
|
42
60
|
/**
|
|
43
61
|
* Unmounts trees that were mounted with render.
|
|
44
62
|
*/
|