@stencil/vitest 1.9.0 → 1.9.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.
@@ -1 +1 @@
1
- {"version":3,"file":"spy-helper.d.ts","sourceRoot":"","sources":["../../src/testing/spy-helper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAM,KAAK,IAAI,EAAE,MAAM,QAAQ,CAAC;AAEvC;;GAEG;AACH,UAAU,aAAa;IACrB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB;;;;;;;;;;;OAWG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAC7B;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;CACtB;AAED;;;GAGG;AACH,MAAM,WAAW,SAAU,SAAQ,aAAa;IAC9C;;;;;;;;;;;;;OAaG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;CAC5C;AAED;;GAEG;AACH,UAAU,gBAAiB,SAAQ,IAAI;IACrC;;;OAGG;IACH,QAAQ,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAC;CACpC;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAC9B;;;OAGG;IACH,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;IACxC;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAC5B;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAChC;;OAEG;IACH,QAAQ,EAAE,GAAG,CAAC;IACd;;OAEG;IACH,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ACxC;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAC5B;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAChC;;OAEG;IACH,QAAQ,EAAE,GAAG,CAAC;IACd;;OAEG;IACH,QAAQ,EAAE,MAAM,IAAI,CAAC;CACtB;AAgDD;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,GAAG,IAAI,CAEjE;AAqLD;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,WAAW,GAAG,cAAc,GAAG,SAAS,CAkBlF;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAQ1D"}
@@ -43,8 +43,8 @@ function resolveConfigForTag(config, tagName) {
43
43
  export function setRenderSpyConfig(config) {
44
44
  pendingRenderConfig = config;
45
45
  }
46
- // Store original define before patching
47
- const origDefine = customElements.define.bind(customElements);
46
+ // Store original define before patching (only in browser/jsdom environments)
47
+ const origDefine = typeof customElements !== 'undefined' ? customElements.define.bind(customElements) : undefined;
48
48
  /**
49
49
  * Apply spies to a target instance (shared logic)
50
50
  */
@@ -158,53 +158,55 @@ function applySpies(target, config) {
158
158
  }
159
159
  return spies;
160
160
  }
161
- // Patch customElements.define to intercept component registration
162
- customElements.define = function (name, ctor, options) {
163
- const lc = name.toLowerCase();
164
- const OrigCtor = ctor;
165
- // Wrap ALL components to enable per-render spies without module-level registration
166
- const Wrapped = class extends OrigCtor {
167
- constructor(...args) {
168
- super(...args);
169
- // Check for spy config: per-render takes priority, then module-level
170
- // Capture config now, at constructor time (before async callbacks)
171
- const baseConfig = pendingRenderConfig || spyTargets[lc];
172
- if (!baseConfig)
173
- return; // No spying configured, quick exit
174
- // Resolve config for this specific tag (handles per-component overrides)
175
- const configToUse = resolveConfigForTag(baseConfig, lc);
176
- if (!configToUse)
177
- return; // No config applies to this tag
178
- // After super(), registerHost has run and we have access to hostRef
179
- const hostRef = this.__stencil__getHostRef?.();
180
- if (hostRef && hostRef.$fetchedCbList$) {
181
- // Lazy-load path: Use $fetchedCbList$ to apply spies after constructor but before render
182
- const element = this;
183
- // Capture config in closure for when callback executes
184
- const capturedConfig = configToUse;
185
- hostRef.$fetchedCbList$.push(() => {
186
- const instance = hostRef.$lazyInstance$;
187
- if (instance) {
188
- const spies = applySpies(instance, capturedConfig);
189
- elementSpies.set(element, spies);
190
- }
191
- });
192
- }
193
- else if (hostRef) {
194
- // Custom-elements output with Stencil runtime: element IS the instance
195
- // Apply spies immediately since there's no lazy loading
196
- const spies = applySpies(this, configToUse);
197
- elementSpies.set(this, spies);
198
- }
199
- else {
200
- // Custom-elements output path: element IS the instance
201
- const spies = applySpies(this, configToUse);
202
- elementSpies.set(this, spies);
161
+ // Patch customElements.define to intercept component registration (only in browser/jsdom environments)
162
+ if (typeof customElements !== 'undefined' && origDefine) {
163
+ customElements.define = function (name, ctor, options) {
164
+ const lc = name.toLowerCase();
165
+ const OrigCtor = ctor;
166
+ // Wrap ALL components to enable per-render spies without module-level registration
167
+ const Wrapped = class extends OrigCtor {
168
+ constructor(...args) {
169
+ super(...args);
170
+ // Check for spy config: per-render takes priority, then module-level
171
+ // Capture config now, at constructor time (before async callbacks)
172
+ const baseConfig = pendingRenderConfig || spyTargets[lc];
173
+ if (!baseConfig)
174
+ return; // No spying configured, quick exit
175
+ // Resolve config for this specific tag (handles per-component overrides)
176
+ const configToUse = resolveConfigForTag(baseConfig, lc);
177
+ if (!configToUse)
178
+ return; // No config applies to this tag
179
+ // After super(), registerHost has run and we have access to hostRef
180
+ const hostRef = this.__stencil__getHostRef?.();
181
+ if (hostRef && hostRef.$fetchedCbList$) {
182
+ // Lazy-load path: Use $fetchedCbList$ to apply spies after constructor but before render
183
+ const element = this;
184
+ // Capture config in closure for when callback executes
185
+ const capturedConfig = configToUse;
186
+ hostRef.$fetchedCbList$.push(() => {
187
+ const instance = hostRef.$lazyInstance$;
188
+ if (instance) {
189
+ const spies = applySpies(instance, capturedConfig);
190
+ elementSpies.set(element, spies);
191
+ }
192
+ });
193
+ }
194
+ else if (hostRef) {
195
+ // Custom-elements output with Stencil runtime: element IS the instance
196
+ // Apply spies immediately since there's no lazy loading
197
+ const spies = applySpies(this, configToUse);
198
+ elementSpies.set(this, spies);
199
+ }
200
+ else {
201
+ // Custom-elements output path: element IS the instance
202
+ const spies = applySpies(this, configToUse);
203
+ elementSpies.set(this, spies);
204
+ }
203
205
  }
204
- }
206
+ };
207
+ return origDefine.call(customElements, name, Wrapped, options);
205
208
  };
206
- return origDefine.call(customElements, name, Wrapped, options);
207
- };
209
+ }
208
210
  /**
209
211
  * Get the spies for a rendered component instance.
210
212
  * Spies are lazily applied on first call to ensure the instance is fully constructed.
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.9.0",
7
+ "version": "1.9.1",
8
8
  "description": "First-class testing utilities for Stencil design systems with Vitest",
9
9
  "license": "MIT",
10
10
  "type": "module",
@@ -100,7 +100,7 @@
100
100
  "dependencies": {
101
101
  "jiti": "^2.6.1",
102
102
  "local-pkg": "^1.1.2",
103
- "vitest-environment-stencil": "1.9.0"
103
+ "vitest-environment-stencil": "1.9.1"
104
104
  },
105
105
  "devDependencies": {
106
106
  "@eslint/js": "^9.39.2",