@stencil/vitest 1.2.0 → 1.3.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/dist/core.d.ts +1 -1
- package/dist/core.d.ts.map +1 -1
- package/dist/core.js +1 -1
- package/dist/testing/render.d.ts +6 -0
- package/dist/testing/render.d.ts.map +1 -1
- package/dist/testing/render.js +26 -7
- package/package.json +2 -2
package/dist/core.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import './testing/matchers.js';
|
|
2
2
|
import './testing/snapshot-serializer.js';
|
|
3
3
|
export { h } from '@stencil/core';
|
|
4
|
-
export { render } from './testing/render.js';
|
|
4
|
+
export { render, waitForStable } from './testing/render.js';
|
|
5
5
|
export { serializeHtml, prettifyHtml, SerializeOptions } from './testing/html-serializer.js';
|
|
6
6
|
export type { RenderOptions, RenderResult } from './types.js';
|
|
7
7
|
//# sourceMappingURL=core.d.ts.map
|
package/dist/core.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":"AACA,OAAO,uBAAuB,CAAC;AAC/B,OAAO,kCAAkC,CAAC;AAE1C,OAAO,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAClC,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":"AACA,OAAO,uBAAuB,CAAC;AAC/B,OAAO,kCAAkC,CAAC;AAE1C,OAAO,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAClC,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAC7F,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/core.js
CHANGED
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
import './testing/matchers.js';
|
|
3
3
|
import './testing/snapshot-serializer.js';
|
|
4
4
|
export { h } from '@stencil/core';
|
|
5
|
-
export { render } from './testing/render.js';
|
|
5
|
+
export { render, waitForStable } from './testing/render.js';
|
|
6
6
|
export { serializeHtml, prettifyHtml } from './testing/html-serializer.js';
|
package/dist/testing/render.d.ts
CHANGED
|
@@ -15,6 +15,12 @@ interface RenderOptions {
|
|
|
15
15
|
*/
|
|
16
16
|
waitForReady?: boolean;
|
|
17
17
|
}
|
|
18
|
+
/**
|
|
19
|
+
* Poll until element has dimensions (is rendered/visible in real browser).
|
|
20
|
+
* Accepts either an Element or a CSS selector string.
|
|
21
|
+
* If a selector is provided, waits for the element to appear in the DOM first.
|
|
22
|
+
*/
|
|
23
|
+
export declare function waitForStable(elementOrSelector: Element | string, timeout?: number): Promise<void>;
|
|
18
24
|
/**
|
|
19
25
|
* Render using Stencil's render
|
|
20
26
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../src/testing/render.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAY,MAAM,aAAa,CAAC;AAE1D,UAAU,aAAa;IACrB;;OAEG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC;;;;OAIG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;
|
|
1
|
+
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../src/testing/render.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAY,MAAM,aAAa,CAAC;AAE1D,UAAU,aAAa;IACrB;;OAEG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC;;;;OAIG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAyBD;;;;GAIG;AACH,wBAAsB,aAAa,CAAC,iBAAiB,EAAE,OAAO,GAAG,MAAM,EAAE,OAAO,SAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAiCtG;AAED;;GAEG;AACH,wBAAsB,MAAM,CAAC,CAAC,SAAS,WAAW,GAAG,WAAW,EAAE,CAAC,GAAG,GAAG,EACvE,KAAK,EAAE,GAAG,EACV,OAAO,GAAE,aAGR,GACA,OAAO,CAAC,YAAY,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CA6I7B"}
|
package/dist/testing/render.js
CHANGED
|
@@ -22,18 +22,37 @@ function isRealBrowser() {
|
|
|
22
22
|
return true;
|
|
23
23
|
}
|
|
24
24
|
/**
|
|
25
|
-
* Poll until element has dimensions (is rendered/visible in real browser)
|
|
25
|
+
* Poll until element has dimensions (is rendered/visible in real browser).
|
|
26
|
+
* Accepts either an Element or a CSS selector string.
|
|
27
|
+
* If a selector is provided, waits for the element to appear in the DOM first.
|
|
26
28
|
*/
|
|
27
|
-
async function
|
|
29
|
+
export async function waitForStable(elementOrSelector, timeout = 5000) {
|
|
30
|
+
if (!isRealBrowser()) {
|
|
31
|
+
console.warn('[waitForStable] Only works in real browser environments');
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
28
34
|
const start = Date.now();
|
|
35
|
+
// Resolve element from selector if needed
|
|
36
|
+
let element = typeof elementOrSelector === 'string' ? null : elementOrSelector;
|
|
37
|
+
// If an Element was passed, verify it's in the DOM
|
|
38
|
+
if (element && !document.contains(element)) {
|
|
39
|
+
console.warn('[waitForStable] Element is not attached to the DOM');
|
|
40
|
+
}
|
|
29
41
|
while (Date.now() - start < timeout) {
|
|
30
|
-
|
|
31
|
-
if (
|
|
32
|
-
|
|
42
|
+
// If we have a selector, try to find the element
|
|
43
|
+
if (typeof elementOrSelector === 'string' && !element) {
|
|
44
|
+
element = document.querySelector(elementOrSelector);
|
|
45
|
+
}
|
|
46
|
+
// If we have an element, check if it has dimensions
|
|
47
|
+
if (element) {
|
|
48
|
+
const rect = element.getBoundingClientRect();
|
|
49
|
+
if (rect.width > 0 && rect.height > 0) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
33
52
|
}
|
|
34
53
|
await new Promise((r) => requestAnimationFrame(r));
|
|
35
54
|
}
|
|
36
|
-
// Don't throw on timeout - element might be intentionally zero-sized
|
|
55
|
+
// Don't throw on timeout - element might be intentionally zero-sized or not found
|
|
37
56
|
}
|
|
38
57
|
/**
|
|
39
58
|
* Render using Stencil's render
|
|
@@ -99,7 +118,7 @@ export async function render(vnode, options = {
|
|
|
99
118
|
if (options.waitForReady !== false) {
|
|
100
119
|
if (isRealBrowser()) {
|
|
101
120
|
// In real browser, poll until element has dimensions
|
|
102
|
-
await
|
|
121
|
+
await waitForStable(element);
|
|
103
122
|
}
|
|
104
123
|
// Always wait for Stencil's update cycle to complete
|
|
105
124
|
await waitForChanges();
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"type": "git",
|
|
5
5
|
"url": "https://github.com/stenciljs/vitest"
|
|
6
6
|
},
|
|
7
|
-
"version": "1.
|
|
7
|
+
"version": "1.3.0",
|
|
8
8
|
"description": "First-class testing utilities for Stencil design systems with Vitest",
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"type": "module",
|
|
@@ -97,7 +97,7 @@
|
|
|
97
97
|
"dependencies": {
|
|
98
98
|
"jiti": "^2.6.1",
|
|
99
99
|
"local-pkg": "^1.1.2",
|
|
100
|
-
"vitest-environment-stencil": "1.
|
|
100
|
+
"vitest-environment-stencil": "1.3.0"
|
|
101
101
|
},
|
|
102
102
|
"devDependencies": {
|
|
103
103
|
"@eslint/js": "^9.39.2",
|