@cronn/element-snapshot 0.9.0 → 0.11.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/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Element Snapshot
1
+ # Element Snapshots
2
2
 
3
3
  Element Snapshots are a custom snapshot implementation inspired by [Playwright's ARIA Snapshots](https://playwright.dev/docs/aria-snapshots#aria-snapshots) and the [Accessibility Object Model](https://wicg.github.io/aom/explainer.html). They cover additional properties, e.g. validation attributes like `required` or `invalid` on form inputs, and are optimized to be serialized as JSON.
4
4
 
@@ -82,13 +82,18 @@ Snapshot options can be passed when calling the snapshot function:
82
82
  ```ts
83
83
  await expect(
84
84
  snapshotElement(page.getByLabel("My select"), {
85
- includeComboboxOptions: true,
85
+ filter: (element) => element.role === "heading",
86
86
  }),
87
87
  ).toMatchJsonFile({
88
- name: "select options",
88
+ name: "headings",
89
89
  });
90
90
  ```
91
91
 
92
+ | Option | Default Value | Description |
93
+ | ------------------------ | ------------- | ------------------------------------------------------------------------------------ |
94
+ | `filter` | `() => true` | Include only elements in the snapshot for which the specified filter returns `true`. |
95
+ | `includeComboboxOptions` | `false` | Include combobox options in the snapshot. |
96
+
92
97
  ### Custom Snapshots
93
98
 
94
99
  The function `snapshotElementRaw` provides the raw element snapshot in a strictly typed structure. This format is not well suited to be read by humans, but can be utilized to derive custom snapshot formats, e.g. for HTML tables.