@stencil/vitest 1.11.1 → 1.11.2

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.
@@ -20,16 +20,6 @@ export declare function serializeHtml(input: HTMLElement | ShadowRoot | Document
20
20
  * Custom HTML prettifier
21
21
  */
22
22
  export declare function prettifyHtml(html: string): string;
23
- /**
24
- * Sort attributes alphabetically within every opening HTML tag in a string.
25
- * Used to normalise expected HTML strings before comparison so that attribute
26
- * order written by hand in tests does not have to match the order produced by
27
- * the runtime (which can differ between dev and prod Stencil builds).
28
- *
29
- * Handles double-quoted attribute values and bare boolean attributes.
30
- * Does NOT touch closing tags, self-closing tags, or text content.
31
- */
32
- export declare function sortAttributesInHtml(html: string): string;
33
23
  /**
34
24
  * Normalize HTML for comparison by removing extra whitespace
35
25
  */
@@ -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;AA6ID;;GAEG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAuDjD;AAED;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAuBzD;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"}
@@ -69,14 +69,10 @@ function serializeElementWithShadow(element, excludeStyles, serializeShadowRoot
69
69
  const tagName = elem.localName || elem.tagName.toLowerCase();
70
70
  // Build opening tag with attributes
71
71
  let html = `<${tagName}`;
72
- // Add attributes sorted alphabetically for deterministic output across dev/prod builds
72
+ // Add attributes
73
73
  if (elem.attributes) {
74
- const attrs = Array.from(elem.attributes).sort((a, b) => {
75
- const nameA = a.prefix && a.localName ? `${a.prefix}:${a.localName}` : a.name;
76
- const nameB = b.prefix && b.localName ? `${b.prefix}:${b.localName}` : b.name;
77
- return nameA < nameB ? -1 : nameA > nameB ? 1 : 0;
78
- });
79
- for (const attr of attrs) {
74
+ for (let i = 0; i < elem.attributes.length; i++) {
75
+ const attr = elem.attributes[i];
80
76
  // Handle namespaced attributes (e.g., xlink:href)
81
77
  // Use prefix + localName if available, otherwise fall back to name
82
78
  let attrName = attr.name;
@@ -220,35 +216,6 @@ export function prettifyHtml(html) {
220
216
  }
221
217
  return lines.join('\n');
222
218
  }
223
- /**
224
- * Sort attributes alphabetically within every opening HTML tag in a string.
225
- * Used to normalise expected HTML strings before comparison so that attribute
226
- * order written by hand in tests does not have to match the order produced by
227
- * the runtime (which can differ between dev and prod Stencil builds).
228
- *
229
- * Handles double-quoted attribute values and bare boolean attributes.
230
- * Does NOT touch closing tags, self-closing tags, or text content.
231
- */
232
- export function sortAttributesInHtml(html) {
233
- // Match opening tags: capture tag name and the rest of the attribute string
234
- return html.replace(/<([a-zA-Z][a-zA-Z0-9:._-]*)((?:\s[^>]*)?)>/g, (_match, tagName, attrStr) => {
235
- if (!attrStr.trim()) {
236
- return `<${tagName}>`;
237
- }
238
- // Parse individual attributes (boolean attrs and attr="value" attrs)
239
- const attrPattern = /\s+([^\s=>"/]+)(?:="([^"]*?)")?/g;
240
- const attrs = [];
241
- let m;
242
- while ((m = attrPattern.exec(attrStr)) !== null) {
243
- attrs.push({ name: m[1], value: m[2] !== undefined ? m[2] : null });
244
- }
245
- attrs.sort((a, b) => (a.name < b.name ? -1 : a.name > b.name ? 1 : 0));
246
- const sortedAttrStr = attrs
247
- .map(({ name, value }) => (value === null ? ` ${name}` : ` ${name}="${value}"`))
248
- .join('');
249
- return `<${tagName}${sortedAttrStr}>`;
250
- });
251
- }
252
219
  /**
253
220
  * Normalize HTML for comparison by removing extra whitespace
254
221
  */
@@ -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;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AAM,GAAG,CAAC,CAAC;IACrC,gHAAgH;IAChH,gBAAgB,CAAC,YAAY,EAAE,MAAM,GAAG,CAAC,CAAC;IAC1C,mDAAmD;IACnD,gBAAgB,IAAI,CAAC,CAAC;IACtB,sFAAsF;IACtF,WAAW,CAAC,YAAY,EAAE,MAAM,GAAG,CAAC,CAAC;IACrC,+FAA+F;IAC/F,gBAAgB,CAAC,YAAY,EAAE,MAAM,GAAG,CAAC,CAAC;IAC1C,yDAAyD;IACzD,mBAAmB,IAAI,CAAC,CAAC;IACzB,6EAA6E;IAC7E,wBAAwB,CAAC,KAAK,EAAE,MAAM,GAAG,CAAC,CAAC;IAC3C,uEAAuE;IACvE,yBAAyB,CAAC,MAAM,EAAE,GAAG,GAAG,CAAC,CAAC;IAC1C,wEAAwE;IACxE,8BAA8B,CAAC,MAAM,EAAE,GAAG,GAAG,CAAC,CAAC;IAC/C,uEAAuE;IACvE,6BAA6B,CAAC,MAAM,EAAE,GAAG,GAAG,CAAC,CAAC;IAC9C,kFAAkF;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,QAAQ,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,GAAG,CAAC,CAAE,SAAQ,cAAc,CAAC,CAAC,CAAC;KAAG;IAC/D,UAAU,4BAA6B,SAAQ,cAAc;KAAG;CACjE;AAioBD,OAAO,EAAE,CAAC"}
@@ -4,7 +4,7 @@
4
4
  * These extend Vitest's expect with Stencil-specific assertions
5
5
  */
6
6
  import { expect } from 'vitest';
7
- import { serializeHtml, normalizeHtml, prettifyHtml, sortAttributesInHtml } from './html-serializer.js';
7
+ import { serializeHtml, normalizeHtml, prettifyHtml } from './html-serializer.js';
8
8
  /**
9
9
  * Check if element has a class
10
10
  */
@@ -313,9 +313,8 @@ function toEqualHtml(received, expected) {
313
313
  expectedHtml = serializeHtml(expectedFragment, { serializeShadowRoot: true, pretty: false });
314
314
  }
315
315
  else {
316
- // For element comparisons, sort attributes so hand-written expected HTML is
317
- // order-independent (dev vs prod builds can reflect props in different orders)
318
- expectedHtml = sortAttributesInHtml(expected.trim());
316
+ // For element comparisons, just normalize to preserve <mock:shadow-root> tags
317
+ expectedHtml = expected.trim();
319
318
  }
320
319
  expectedHtml = normalizeHtml(expectedHtml);
321
320
  receivedHtml = normalizeHtml(receivedHtml);
@@ -366,9 +365,8 @@ function toEqualLightHtml(received, expected) {
366
365
  expectedHtml = serializeHtml(expectedFragment, { serializeShadowRoot: false, pretty: false });
367
366
  }
368
367
  else {
369
- // For element comparisons, sort attributes so hand-written expected HTML is
370
- // order-independent (dev vs prod builds can reflect props in different orders)
371
- expectedHtml = sortAttributesInHtml(expected.trim());
368
+ // For element comparisons, just normalize to preserve <mock:shadow-root> tags
369
+ expectedHtml = expected.trim();
372
370
  }
373
371
  expectedHtml = normalizeHtml(expectedHtml);
374
372
  receivedHtml = normalizeHtml(receivedHtml);
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.1",
7
+ "version": "1.11.2",
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.1"
107
+ "vitest-environment-stencil": "1.11.2"
108
108
  },
109
109
  "devDependencies": {
110
110
  "@eslint/js": "^9.39.2",