@cronn/element-snapshot 0.26.0 → 0.27.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/index.d.mts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { Expect, Locator, MatcherReturnType } from "@playwright/test";
2
2
  import { PlaywrightMatchJsonFileOptions, PlaywrightMatchTextFileOptions, PlaywrightValidationFileMatcherConfig } from "@cronn/playwright-file-snapshots";
3
+ import { MarkdownTableNormalizer } from "@cronn/lib-file-snapshots";
3
4
  //#region src/playwright/markdown-table.d.ts
4
5
  interface MarkdownTableSnapshotOptions {
5
6
  /**
@@ -8,6 +9,10 @@ interface MarkdownTableSnapshotOptions {
8
9
  * @default true
9
10
  */
10
11
  showSortIndicator?: boolean;
12
+ /**
13
+ * Custom normalizers to apply before serialization
14
+ */
15
+ normalizers?: Array<MarkdownTableNormalizer>;
11
16
  }
12
17
  /**
13
18
  * Creates a Markdown table snapshot from a table or grid element
@@ -252,7 +257,7 @@ interface ElementSnapshotMatchers {
252
257
  toMatchMarkdownTableSnapshotFile: (actual: Locator, options?: MatchMarkdownTableSnapshotFileOptions) => Promise<MatcherReturnType>;
253
258
  }
254
259
  interface MatchSemanticSnapshotFileOptions extends PlaywrightMatchJsonFileOptions, SemanticSnapshotOptions {}
255
- interface MatchMarkdownTableSnapshotFileOptions extends Omit<PlaywrightMatchTextFileOptions, "fileExtension">, MarkdownTableSnapshotOptions {}
260
+ interface MatchMarkdownTableSnapshotFileOptions extends Omit<PlaywrightMatchTextFileOptions, "fileExtension" | "normalizers">, MarkdownTableSnapshotOptions {}
256
261
  //#endregion
257
262
  //#region src/playwright/matchers.d.ts
258
263
  /**
package/dist/index.mjs CHANGED
@@ -236,8 +236,9 @@ const sortIndicators = {
236
236
  * Creates a Markdown table snapshot from a table or grid element
237
237
  */
238
238
  async function markdownTableSnapshot(locator, options = {}) {
239
- const parsedTable = parseTable(await rawSnapshot(locator), options);
240
- return new MarkdownTableSerializer().serialize(parsedTable);
239
+ const { showSortIndicator, normalizers } = options;
240
+ const parsedTable = parseTable(await rawSnapshot(locator), { showSortIndicator });
241
+ return new MarkdownTableSerializer({ normalizers }).serialize(parsedTable);
241
242
  }
242
243
  function parseTable(snapshot, options) {
243
244
  const { showSortIndicator = true } = options;
@@ -285,8 +286,13 @@ function defineElementSnapshotMatchers(config = {}) {
285
286
  return await defineJsonFileMatcher("toMatchSemanticSnapshotFile", config).bind(this)(() => semanticSnapshot(actual, options), options);
286
287
  }
287
288
  async function toMatchMarkdownTableSnapshotFile(actual, options = {}) {
288
- return await defineTextFileMatcher("toMatchMarkdownTableSnapshotFile", config).bind(this)(() => markdownTableSnapshot(actual, options), {
289
- ...options,
289
+ const toMatchTextFile = defineTextFileMatcher("toMatchMarkdownTableSnapshotFile", config).bind(this);
290
+ const { showSortIndicator, normalizers, ...matchFileOptions } = options;
291
+ return await toMatchTextFile(() => markdownTableSnapshot(actual, {
292
+ showSortIndicator,
293
+ normalizers
294
+ }), {
295
+ ...matchFileOptions,
290
296
  fileExtension: "md"
291
297
  });
292
298
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cronn/element-snapshot",
3
- "version": "0.26.0",
3
+ "version": "0.27.0",
4
4
  "description": "Element snapshots for Playwright",
5
5
  "homepage": "https://cronn.github.io/file-snapshots/playwright/element-snapshots/",
6
6
  "bugs": {
@@ -46,9 +46,9 @@
46
46
  "typescript-eslint": "8.65.0",
47
47
  "vitest": "4.1.10",
48
48
  "node": "runtime:24.18.1",
49
- "@cronn/vitest-file-snapshots": "2.1.2",
49
+ "@cronn/shared-configs": "0.0.0",
50
50
  "@cronn/test-utils": "0.0.0",
51
- "@cronn/shared-configs": "0.0.0"
51
+ "@cronn/vitest-file-snapshots": "2.1.2"
52
52
  },
53
53
  "peerDependencies": {
54
54
  "@playwright/test": "^1.55"