This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Commit c469791
authored
[web:tests] switch to new HTML DOM matcher (#52354)
Remove the over-architected and under-utilized `canonicalizeHtml` and `HtmlComparisonMode`. Replace with a new `hasHtml` matcher.
The new matcher produces considerably better error messages when matching fails (see `matchers_test.dart` for multiple examples). It also allows focusing on particular parts of the DOM rather than looking for a full match. This way a test can test just the functionality it cares about, and it can skip specifying what unrelated parts should look like (i.e. it prevents over-testing). For example, let's say you want to test that an `<flt-semantics>` element has an `aria-label` attribute. You can use a DOM pattern that specified just that:
```
expect(
element,
hasHtml('<flt-semantics aria-label="hello"></flt-semantics>'),
)
```
This will check for the existence of `<flt-semantics>` and `aria-label="hello"`. It will ignore everything else that's unrelated to ARIA labels. For example, the element may have its geometry specified in the `style` attribute, an `id` attribute, and many other things, but if the test doesn't care, it doesn't need to specify those things (it can, if needs to though). This also applies to `style` properties. See more examples in the `matchers_test.dart` file.1 parent cac3b87 commit c469791
File tree
7 files changed
+598
-252
lines changed- lib/web_ui
- lib/src/engine
- test
- common
- engine
- semantics
- surface
7 files changed
+598
-252
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
597 | 597 | | |
598 | 598 | | |
599 | 599 | | |
600 | | - | |
601 | | - | |
602 | | - | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
603 | 603 | | |
604 | 604 | | |
605 | 605 | | |
| |||
0 commit comments