Techies Blog
Apr 03, 2022

Unit Testing

But some things are easier to unit test than others. Specifically, unit tests work great for : Functions which given the same input, always return the same output, and have no side-effects.

Often, UI components don’t fall into that category of things which are easy to unit test, which makes it harder to stick to the discipline of TDD: Writing tests first.

Writing tests first is necessary to achieve some of the benefits I listed: architecture improvements, better developer experience design, and quicker feedback as you’re developing your app. It takes discipline and practice to train yourself to use TDD. Many developers prefer to tinker before they write tests, but if you don’t write tests first, you rob yourself of a lot of the best features of unit tests.

It’s worth the practice and discipline, though. TDD with unit tests can train you to write UI components which are far simpler, easier to maintain, and easier to compose and reuse with other components.

One recent innovation in my testing discipline is the development of the , which is a tiny wrapper around that helps you write simpler, more maintainable tests.

No matter what framework you use, the following tips will help you write better, more testable, more readable, more composable UI components:

ragool

ragool

Web Developer.

Leave a Reply

Related Posts

Categories