@stencil/vitest 1.1.19 → 1.1.21

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":"html-serializer.d.ts","sourceRoot":"","sources":["../../src/testing/html-serializer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAkCH,MAAM,WAAW,gBAAgB;IAC/B,qDAAqD;IACrD,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,qCAAqC;IACrC,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,oCAAoC;IACpC,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAC3B,KAAK,EAAE,WAAW,GAAG,UAAU,GAAG,gBAAgB,GAAG,MAAM,EAC3D,OAAO,GAAE,gBAAqB,GAC7B,MAAM,CAWR;AAyID;;GAEG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAkDjD;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAElD"}
1
+ {"version":3,"file":"html-serializer.d.ts","sourceRoot":"","sources":["../../src/testing/html-serializer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAkCH,MAAM,WAAW,gBAAgB;IAC/B,qDAAqD;IACrD,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,qCAAqC;IACrC,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,oCAAoC;IACpC,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAC3B,KAAK,EAAE,WAAW,GAAG,UAAU,GAAG,gBAAgB,GAAG,MAAM,EAC3D,OAAO,GAAE,gBAAqB,GAC7B,MAAM,CAWR;AAyID;;GAEG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAuDjD;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAElD"}
@@ -195,14 +195,18 @@ export function prettifyHtml(html) {
195
195
  lines.push(' '.repeat(indentLevel * indentSize) + part);
196
196
  }
197
197
  else if (part.endsWith('/>')) {
198
- // Self-closing tag
198
+ // Self-closing tag (XML style)
199
199
  lines.push(' '.repeat(indentLevel * indentSize) + part);
200
200
  }
201
201
  else {
202
202
  // Opening tag
203
203
  lines.push(' '.repeat(indentLevel * indentSize) + part);
204
- // Increase indent for next content
205
- indentLevel++;
204
+ // Check if it's a void element - if so, don't increase indent
205
+ const tagName = part.match(/<([^\s>/]+)/)?.[1]?.toLowerCase();
206
+ if (!tagName || !VOID_ELEMENTS.has(tagName)) {
207
+ // Not a void element, increase indent for next content
208
+ indentLevel++;
209
+ }
206
210
  }
207
211
  }
208
212
  else {
@@ -1 +1 @@
1
- {"version":3,"file":"matchers.d.ts","sourceRoot":"","sources":["../../src/testing/matchers.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH;;GAEG;AACH,UAAU,cAAc,CAAC,CAAC,GAAG,OAAO;IAClC,mDAAmD;IACnD,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,CAAC,CAAC;IAClC,qDAAqD;IACrD,aAAa,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC;IACvC,gFAAgF;IAChF,cAAc,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC;IACxC,2EAA2E;IAC3E,eAAe,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC;IACtD,mEAAmE;IACnE,gBAAgB,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,CAAC,CAAC;IACtD,sEAAsE;IACtE,iBAAiB,CAAC,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC;IAC5D,0EAA0E;IAC1E,cAAc,CAAC,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AAkF;IAClF,4BAA4B,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,GAAG,CAAC,CAAC;CAC7D;AAGD,OAAO,QAAQ,QAAQ,CAAC;IACtB,UAAU,SAAS,CAAC,CAAC,GAAG,GAAG,CAAE,SAAQ,cAAc,CAAC,CAAC,CAAC;KAAG;IACzD,UAAU,4BAA6B,SAAQ,cAAc;KAAG;CACjE;AAyiBD,OAAO,EAAE,CAAC"}
@@ -214,11 +214,14 @@ function toEqualHtml(received, expected) {
214
214
  throw new TypeError(`Element must be a resolved value, not a promise, before it can be tested`);
215
215
  }
216
216
  let receivedHtml;
217
+ let isStringComparison = false;
217
218
  // Serialize the received value
218
219
  if (typeof received === 'string') {
220
+ isStringComparison = true;
219
221
  const fragment = parseHtmlFragment(received);
220
- // For string inputs, use innerHTML to avoid template wrapper
221
- receivedHtml = fragment.innerHTML || fragment.textContent || '';
222
+ // Use serializeHtml to preserve all elements including the outer ones
223
+ // Don't prettify for comparison - we'll normalize instead
224
+ receivedHtml = serializeHtml(fragment, { serializeShadowRoot: true, pretty: false });
222
225
  }
223
226
  else if (received.nodeType === 11) {
224
227
  // Document fragment
@@ -232,9 +235,17 @@ function toEqualHtml(received, expected) {
232
235
  throw new TypeError(`expect.toEqualHtml() value should be an element, shadow root, or string`);
233
236
  }
234
237
  // Parse and serialize expected HTML for consistent formatting
235
- // For expected HTML, just normalize whitespace without parsing through DOM
236
- // to preserve custom elements like <mock:shadow-root>
237
- let expectedHtml = normalizeHtml(expected.trim());
238
+ let expectedHtml;
239
+ if (isStringComparison) {
240
+ // When comparing strings, parse and serialize both the same way
241
+ const expectedFragment = parseHtmlFragment(expected.trim());
242
+ expectedHtml = serializeHtml(expectedFragment, { serializeShadowRoot: true, pretty: false });
243
+ }
244
+ else {
245
+ // For element comparisons, just normalize to preserve <mock:shadow-root> tags
246
+ expectedHtml = expected.trim();
247
+ }
248
+ expectedHtml = normalizeHtml(expectedHtml);
238
249
  receivedHtml = normalizeHtml(receivedHtml);
239
250
  const pass = receivedHtml === expectedHtml;
240
251
  return {
@@ -255,11 +266,14 @@ function toEqualLightHtml(received, expected) {
255
266
  throw new TypeError(`Element must be a resolved value, not a promise, before it can be tested`);
256
267
  }
257
268
  let receivedHtml;
269
+ let isStringComparison = false;
258
270
  // Serialize the received value (without shadow DOM)
259
271
  if (typeof received === 'string') {
272
+ isStringComparison = true;
260
273
  const fragment = parseHtmlFragment(received);
261
- // For string inputs, use innerHTML to avoid template wrapper
262
- receivedHtml = fragment.innerHTML || fragment.textContent || '';
274
+ // Use serializeHtml to preserve all elements including the outer ones
275
+ // Don't prettify for comparison - we'll normalize instead
276
+ receivedHtml = serializeHtml(fragment, { serializeShadowRoot: false, pretty: false });
263
277
  }
264
278
  else if (received.nodeType === 11) {
265
279
  // Document fragment
@@ -272,9 +286,18 @@ function toEqualLightHtml(received, expected) {
272
286
  else {
273
287
  throw new TypeError(`expect.toEqualLightHtml() value should be an element, shadow root, or string`);
274
288
  }
275
- // For expected HTML, just normalize whitespace without parsing through DOM
276
- // to preserve custom elements like <mock:shadow-root>
277
- let expectedHtml = normalizeHtml(expected.trim());
289
+ // Parse and serialize expected HTML for consistent formatting
290
+ let expectedHtml;
291
+ if (isStringComparison) {
292
+ // When comparing strings, parse and serialize both the same way
293
+ const expectedFragment = parseHtmlFragment(expected.trim());
294
+ expectedHtml = serializeHtml(expectedFragment, { serializeShadowRoot: false, pretty: false });
295
+ }
296
+ else {
297
+ // For element comparisons, just normalize to preserve <mock:shadow-root> tags
298
+ expectedHtml = expected.trim();
299
+ }
300
+ expectedHtml = normalizeHtml(expectedHtml);
278
301
  receivedHtml = normalizeHtml(receivedHtml);
279
302
  const pass = receivedHtml === expectedHtml;
280
303
  return {
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.1.19",
7
+ "version": "1.1.21",
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.1.19"
100
+ "vitest-environment-stencil": "1.1.21"
101
101
  },
102
102
  "devDependencies": {
103
103
  "@eslint/js": "^9.39.2",