0

Is unit test helpful in React web app? Why do I think it is just wasting of time? How often do you use unit test in your web app development?

Comments
  • 1
    Unit tests are useful (and frankly mandatory) for any kind of business logic, wherever it is implemented.

    What makes them look wasteful in your eyes?
  • 1
    @Commodore Because react. You first need to refactor people's crap to make components testable. Then, write long and complicated tests. Finally, bang your head against keyboard every time tests break, and tests break all the time.
  • 0
    I only unit test functions. I throw components to a visual regression test service
  • 1
    Yes, but you need to create the tests first.

    If you create the tests first, you'll wind up designing functional and testable code.

    If you create the code first and than try to test, you'll bang your head against the keyboard and think unit testing is a horrible idea that barely functions and breaks often.
  • 1
    The sheer fact that you question the use of tests scares me.
  • 0
    @Commodore I think @h3rp1d3v has explained most of how I feel. For function test I believe unit tests are helpful and worth the effort, because I just have to provide some input and check the output. It is black box testing for me.
    But for component tests, I need to understand the implementation first and possibly need to mock its dependencies here and there. Besides, there will be a lot of test cases where we have many diverge paths, like, we need to mock a lot of input one after another then we can test different options after that. Then we have long and complicated tests.
  • 0
    @h3rp1d3v sir, you shared the same feel as I do.
    btw, what is visual regression test service?
  • 0
    @lungdart Yes. I am writing tests after implementation. That's why I am wondering whether it will be totally different if we write tests first. But how do I feel for UI tests I still need to know about implementation before tests. Then we are still doing implementation before tests, virtually.
  • 1
    @Lyniven sorry for scaring you. I am trying to embrace unit tests too. But it just doesn't feel right for me. That's why I turn to the community.🥲
  • 0
    If anyone have good practical examples of testing/TDD, in forms of video or documents, could you please share it with me? I really appreciate that.
  • 1
  • 1
    @hoggchan designing test first will show you how to implement as dictionary as you can, and what components need to be tested at an integration level rather than a unit level
Add Comment