this post was submitted on 15 Jun 2024
721 points (98.3% liked)

Programmer Humor

32472 readers
988 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 5 years ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 62 points 5 months ago (6 children)

I like how garage is a class but car is an intrinsic element.

[–] [email protected] 14 points 5 months ago (4 children)

Idk why exactly but using IDs for styling has been discouraged for a while and now every application I've ever worked on had been styled using classes that are usually unique anyway

[–] [email protected] 4 points 5 months ago (1 children)

Should I bother using just classes or can I keep making ids?

[–] [email protected] 2 points 5 months ago (1 children)

Tbh, I think for unique elements that's a valid approach. It also enables easier element selection in automated e2e testing

[–] [email protected] 5 points 5 months ago* (last edited 5 months ago) (1 children)

In E2E tests you should ideally be finding elements using labels or ARIA roles. The point of an E2E test is to use the app in the same way a user would, and users don't look for elements by class name or ID, and definitely not by data-testid.

The more your test deviates from how real users use the system, the more likely it is that the test will break even though the actual user experience is fine, or vice versa.

This is encouraged by Testing Library and related libraries like React Testing Library. Those are for unit and integration tests though, not E2E tests. I'm not as familiar with the popular E2E testing frameworks these days (we use an internally developed one at work).

[–] [email protected] 1 points 5 months ago

I agree, but our tester is a bit lazy I suppose

load more comments (2 replies)
load more comments (3 replies)