4 ms·
I've used two techniques: 1) use a prefix (t-) for test selectors and do not attach any styles to them (put them on the elements you need to target directly so
by steveax 10y ago
I've used two techniques:
1) use a prefix (t-) for test selectors and do not attach any styles to them (put them on the elements you need to target directly so the tests do not have to know about the DOM structure)
2) use data- attributes for test selectors (again directly on the target elements so DOM changes won't break the tests)
The second I got from this article, which is a bit Ember specific, but makes a lot of good recommendations:
https://dockyard.com/blog/2015/09/25/ember-best-practices-acceptance-tests https://dockyard.com/blog/2015/09/25/ember-best-practices-ac...
- blowski 10y agoActually this is a really good idea... But I was referring to to testing the CSS itself - in the same way I text my JavaScript. I'd love to have a suite of tests that say "this element should be 10px from the left of the page" or something like that. I've seen tools that attempt to make this possible but they are hard to work with. Thanks for the suggestion on how to work with test classes anyway. Very useful.
- steveax 10y agoProbably the best way to test things like that is with a visual regression testing tool [1][2]. In practice these are difficult to get right and tend to produce a lot of false positives and negatives. See for instance Huxley [3] [1]: https://github.com/BBC-News/wraith https://github.com/BBC-News/wraith [2]: https://percy.io/ https://percy.io/ [3]: https://github.com/facebookarchive/huxley https://github.com/facebookarchive/huxley