guides-source icon indicating copy to clipboard operation
guides-source copied to clipboard

Requesting review of Ember test selectors (data-test) excerpt from the testing guide

Open OmShiv opened this issue 3 years ago • 0 comments

I am interested to know how I can request a change of these excerpts from the Testing guides, and whom I can reach for the following concerns. Kindly guide.

excerpt

https://github.com/ember-learn/guides-source/blob/1ae44e82e19f641af4156f8c48b09b3172641c6b/guides/release/testing/testing-tools.md?plain=1#L92

Class names and DOM structure change over time—for the better—by you, your team, and addon developers. If you rely on CSS classes, your tests will break and need a significant rewrite

concern

When DOM changes are unavoidable, it is natural that the data-test selectors will also need to be moved, and refactored. How does using data-test selectors provide any perceivable/measurable value?

excerpt

https://github.com/ember-learn/guides-source/blob/1ae44e82e19f641af4156f8c48b09b3172641c6b/guides/release/testing/testing-tools.md?plain=1#L99

If you rely on CSS classes, your tests will break and need a significant rewrite.

concern

Don’t we want this? Classes are part of the user experience, so tests should break if they change. If not, then this concern is also applicable to data-test selectors. That is, when you change the DOM you also need to move/change data-test selectors without which the tests will break in a similar fashion and will need rewrite.

In that case, data-test selector becomes useful exactly in this case when you have an element

  • that can change the type (span ➞ div ➞ li, etc),
  • can change the class,
  • but still, needs to play the same role? This is not common and is sometimes unrealistic.

OmShiv avatar Oct 20 '22 18:10 OmShiv