DEV Community

Discussion on: Stop! Don't test that!

Collapse
 
eljayadobe profile image
Eljay-Adobe

When I read unit tests I think TDD-style unit tests.

Are those the kind of unit tests you are referring to?

The TDD-style unit tests are not created for the purpose of testing, they are created for the purpose of design. As a byproduct, having a suite of unit tests to ensure basic correctness and detect basic correctness regressions is a nice residual value.

TDD has a very strong stance to avoid writing unit tests pre-maturely. Rather it advocates just-in-time creation of unit tests, and not a moment before.

I'm not familiar with Jest. Probably would have been useful back when I was working in TypeScript.

Collapse
 
klamping profile image
Kevin Lamping

I love the concept of TDD, but have found it applies more to server-side type scripts than front-end work. For front-end, there's a lot of user interaction embedded in the code, which can make TDD harder to practice (but not impossible).

Some of the most fun I've had writing code was building out a component TDD style. That said, the component had very little user interaction, but a lot of logic going on. It fit the bill perfectly for TDD.

Thanks for the response!

Collapse
 
eljayadobe profile image
Eljay-Adobe

One of the big proponents of TDD is Robert Martin.

Robert Martin does not think user interaction (UI) part of a program is suitable for TDD, as per When TDD Does Not Work.

Just thought you might be interested. ;-)