CSS Unit Testing

前端 未结 9 1715
面向向阳花
面向向阳花 2020-12-24 05:35

A few quick searches discovered that I\'m obviously not the first person to have the thought \"Can I unit test my CSS?\".

I\'m wondering if anyone

9条回答
  •  Happy的楠姐
    2020-12-24 06:29

    We’ve set up unit tests on a large, UI-heavy project and it worked wonderfully! It was also way easier than it looks.

    Take simple tools like getBoundingClientRect or getComputedStyle, pair it with hyperscript to create quick temporary DOM trees and you’re good to go. We’ve written tape-css to reduce boilerplate when testing with tape, but the stack will be similar in any test setup.

    Yesterday I published a detailed blog post with a simple tutorial and live examples about our new workflow and how it boosted our productivity: How CSS unit tests helped us move fast.

提交回复
热议问题