ember-learn / ember-learn/guides-source

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

Open
#1,855 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
HTML
Stars
161
Forks
512
Avg merge
4d 9h
Merged PRs (30d)
4

Description

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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.