@stencil/vitest 1.11.5 → 1.12.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/plugin.d.ts.map +1 -1
- package/dist/plugin.js +11 -12
- package/dist/testing/render.d.ts +7 -0
- package/dist/testing/render.d.ts.map +1 -1
- package/dist/testing/render.js +2 -2
- package/package.json +2 -2
package/dist/plugin.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAE5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,GAAE;IAAE,GAAG,CAAC,EAAE,OAAO,CAAA;CAAO,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAE5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,GAAE;IAAE,GAAG,CAAC,EAAE,OAAO,CAAA;CAAO,GAAG,MAAM,CAgGxE"}
|
package/dist/plugin.js
CHANGED
|
@@ -43,13 +43,14 @@ export function stencilVitestPlugin(opts = {}) {
|
|
|
43
43
|
if (id.includes('.css') && id.includes('tag=')) {
|
|
44
44
|
const [relPath] = id.split('?');
|
|
45
45
|
const query = id.slice(id.indexOf('?'));
|
|
46
|
-
// Strip virtual prefix from importer if present
|
|
47
46
|
const realImporter = importer?.startsWith('\0stencil-style:')
|
|
48
47
|
? importer.slice('\0stencil-style:'.length).split('?')[0] + '.css'
|
|
49
48
|
: importer;
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
49
|
+
// Resolve bare specifiers from node_modules, otherwise resolve relative to importer
|
|
50
|
+
const resolved = !relPath.startsWith('.') && !relPath.startsWith('/')
|
|
51
|
+
? resolve(process.cwd(), 'node_modules', relPath.replace(/^~/, ''))
|
|
52
|
+
: resolve(dirname(realImporter), relPath);
|
|
53
|
+
return '\0stencil-style:' + resolved.replace(/\.css$/, '') + (query || '');
|
|
53
54
|
}
|
|
54
55
|
return null;
|
|
55
56
|
},
|
|
@@ -63,15 +64,13 @@ export function stencilVitestPlugin(opts = {}) {
|
|
|
63
64
|
},
|
|
64
65
|
async transform(code, id) {
|
|
65
66
|
if (id.startsWith('\0stencil-style:')) {
|
|
66
|
-
// Reconstruct the original .css path for Stencil's transpiler (it uses extension to detect file type)
|
|
67
67
|
const pathWithoutPrefix = id.slice('\0stencil-style:'.length);
|
|
68
68
|
const [basePath, query] = pathWithoutPrefix.split('?');
|
|
69
69
|
const originalPath = basePath + '.css' + (query ? '?' + query : '');
|
|
70
|
-
const result = await transpile(code, {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
};
|
|
70
|
+
const result = await transpile(code, {
|
|
71
|
+
file: originalPath,
|
|
72
|
+
});
|
|
73
|
+
return { code: result.code, map: null };
|
|
75
74
|
}
|
|
76
75
|
// Only transform .tsx files
|
|
77
76
|
if (!id.endsWith('.tsx')) {
|
|
@@ -94,14 +93,14 @@ export function stencilVitestPlugin(opts = {}) {
|
|
|
94
93
|
// 'customelement' appends a customElements.define() call so the component
|
|
95
94
|
// self-registers the moment this module is imported — no loader needed.
|
|
96
95
|
componentExport: 'customelement',
|
|
97
|
-
componentMetadata: '
|
|
96
|
+
componentMetadata: 'runtimestatic',
|
|
98
97
|
currentDirectory: process.cwd(),
|
|
99
98
|
module: 'esm',
|
|
100
99
|
proxy: null,
|
|
101
100
|
sourceMap: false,
|
|
102
101
|
style: opts.css ? 'static' : null,
|
|
103
102
|
styleImportData: opts.css ? 'queryparams' : null,
|
|
104
|
-
target: '
|
|
103
|
+
target: 'es2017',
|
|
105
104
|
// Don't rewrite import paths — let Vite handle resolution via aliases
|
|
106
105
|
transformAliasedImportPaths: false,
|
|
107
106
|
});
|
package/dist/testing/render.d.ts
CHANGED
|
@@ -19,6 +19,13 @@ interface RenderOptions {
|
|
|
19
19
|
* Spy configuration for this render call. Spies on methods, props, and lifecycle hooks.
|
|
20
20
|
*/
|
|
21
21
|
spyOn?: SpyConfig;
|
|
22
|
+
/**
|
|
23
|
+
* The CustomElementRegistry in which the component is defined.
|
|
24
|
+
* Defaults to the global `customElements`. Pass a scoped registry when
|
|
25
|
+
* testing Scoped Custom Element Registry scenarios so that
|
|
26
|
+
* `whenDefined()` resolves against the correct registry.
|
|
27
|
+
*/
|
|
28
|
+
registry?: CustomElementRegistry;
|
|
22
29
|
}
|
|
23
30
|
/**
|
|
24
31
|
* Poll until element has dimensions (is rendered/visible in real browser).
|
|
@@ -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;AAC1D,OAAO,EAAyC,KAAK,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAExF,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;IACvB;;OAEG;IACH,KAAK,CAAC,EAAE,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../src/testing/render.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAY,MAAM,aAAa,CAAC;AAC1D,OAAO,EAAyC,KAAK,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAExF,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;IACvB;;OAEG;IACH,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,qBAAqB,CAAC;CAClC;AA+FD;;;;GAIG;AACH,wBAAsB,aAAa,CAAC,iBAAiB,EAAE,OAAO,GAAG,MAAM,EAAE,OAAO,SAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAyCtG;AAED;;;;GAIG;AACH,wBAAsB,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,SAAO,GAAG,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,CAY5F;AAED;;GAEG;AACH,wBAAsB,MAAM,CAAC,CAAC,SAAS,WAAW,GAAG,WAAW,EAAE,CAAC,GAAG,GAAG,EACvE,QAAQ,EAAE,GAAG,GAAG,MAAM,EACtB,OAAO,GAAE,aAGR,GACA,OAAO,CAAC,YAAY,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAyL7B"}
|
package/dist/testing/render.js
CHANGED
|
@@ -176,7 +176,7 @@ export async function render(template, options = {
|
|
|
176
176
|
}
|
|
177
177
|
else {
|
|
178
178
|
// Use Stencil's render which handles VNodes properly in the browser
|
|
179
|
-
|
|
179
|
+
stencilRender(template, container);
|
|
180
180
|
}
|
|
181
181
|
// Get the rendered element
|
|
182
182
|
const element = container.firstElementChild;
|
|
@@ -220,7 +220,7 @@ export async function render(template, options = {
|
|
|
220
220
|
// Wait for custom element to be defined
|
|
221
221
|
const tagName = element.tagName.toLowerCase();
|
|
222
222
|
if (tagName.includes('-')) {
|
|
223
|
-
await customElements.whenDefined(tagName);
|
|
223
|
+
await (options.registry ?? customElements).whenDefined(tagName);
|
|
224
224
|
}
|
|
225
225
|
// Wait for component to be ready
|
|
226
226
|
if (typeof element.componentOnReady === 'function') {
|
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.12.0",
|
|
8
8
|
"description": "First-class testing utilities for Stencil design systems with Vitest",
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"type": "module",
|
|
@@ -104,7 +104,7 @@
|
|
|
104
104
|
"dependencies": {
|
|
105
105
|
"jiti": "^2.6.1",
|
|
106
106
|
"local-pkg": "^1.1.2",
|
|
107
|
-
"vitest-environment-stencil": "1.
|
|
107
|
+
"vitest-environment-stencil": "1.12.0"
|
|
108
108
|
},
|
|
109
109
|
"devDependencies": {
|
|
110
110
|
"@eslint/js": "^9.39.2",
|