@stencil/vitest 1.11.6 → 1.12.1

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.
@@ -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;CACnB;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"}
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,CA4L7B"}
@@ -145,7 +145,10 @@ export async function render(template, options = {
145
145
  clearStage: true,
146
146
  stageAttrs: { class: 'stencil-component-stage' },
147
147
  }) {
148
- const container = document.createElement('div');
148
+ // @ts-ignore - customElementRegistry is new and it's fine
149
+ const container = document.createElement('div', {
150
+ customElementRegistry: options.registry ?? customElements,
151
+ });
149
152
  Object.entries(options.stageAttrs || {}).forEach(([key, value]) => {
150
153
  container.setAttribute(key, value);
151
154
  });
@@ -176,7 +179,7 @@ export async function render(template, options = {
176
179
  }
177
180
  else {
178
181
  // Use Stencil's render which handles VNodes properly in the browser
179
- await stencilRender(template, container);
182
+ stencilRender(template, container);
180
183
  }
181
184
  // Get the rendered element
182
185
  const element = container.firstElementChild;
@@ -220,7 +223,7 @@ export async function render(template, options = {
220
223
  // Wait for custom element to be defined
221
224
  const tagName = element.tagName.toLowerCase();
222
225
  if (tagName.includes('-')) {
223
- await customElements.whenDefined(tagName);
226
+ await (options.registry ?? customElements).whenDefined(tagName);
224
227
  }
225
228
  // Wait for component to be ready
226
229
  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.11.6",
7
+ "version": "1.12.1",
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.11.6"
107
+ "vitest-environment-stencil": "1.12.1"
108
108
  },
109
109
  "devDependencies": {
110
110
  "@eslint/js": "^9.39.2",