I think Unit tests are not suited for modern frontend development. I'm a backend developer and doing Unit testing in RoR is simple and makes all the sense as we have classes and instance methods.
In modern frontend frameworks, it looks more obvious to do integration and snapshot testing and this has been a good experience my coworker has had in one of our projects.
I also think is important more frontend developers start/continue doing testing BUT the testing the helps them do their job and doesn't add trouble to their daily tasks.
You may be aware of this talk between DHH, Martin Fowler and Kent Beck, which came about as a result of confusion about how to unit test Ruby on Rails.
Frameworks do make it harder to unit test, but it doesnβt make it impossible.
With Ruby on Rails a key example is Active Record. This pattern makes it difficult to write βunitβ tests because itβs hard to test an Active Record model without interacting with a real database resource. For some people this breaks a rule about what a unit test should be. They then replace Active Record with something like the repository pattern. For people like myself, we just shrug our shoulders and use the database, and still call it unit testing. Sure, my tests arenβt as fast as they might otherwise be, but Iβm still gaining all the other benefits of unit tests over higher-level tests.
On the front-end... I think your use of the word simple is important. People donβt believe that unit testing UI code is simple. In my opinion, thatβs why they donβt do it. And since I know that Iβm having a lot of success with unit testing on the front-end, Iβm trying to share that knowledge with others.
I'm in the group of people who think doing unit testing in frontend isn't simple π
One of the reasons I think people feel that way is that it isn't obvious what to unit test in frontend world. Do we test styles? Do we test structure of HTML? Of course we should be testing JS functions but what about event handlers? Probably we've been doing it wrong.
And even though your article answers those questions, doing unit tests in the way you mentioned isn't as easy as frontend devs would like/hope.
since I know that Iβm having a lot of success with unit testing on the front-end, Iβm trying to share that knowledge with others
Then I hope to see your content about this topic π
BTW, I wasn't aware of the DHH, Fowler, and Beck video. Thanks for sharing ππ½
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I think Unit tests are not suited for modern frontend development. I'm a backend developer and doing Unit testing in RoR is simple and makes all the sense as we have classes and instance methods.
In modern frontend frameworks, it looks more obvious to do integration and snapshot testing and this has been a good experience my coworker has had in one of our projects.
I also think is important more frontend developers start/continue doing testing BUT the testing the helps them do their job and doesn't add trouble to their daily tasks.
You may be aware of this talk between DHH, Martin Fowler and Kent Beck, which came about as a result of confusion about how to unit test Ruby on Rails.
Frameworks do make it harder to unit test, but it doesnβt make it impossible.
With Ruby on Rails a key example is Active Record. This pattern makes it difficult to write βunitβ tests because itβs hard to test an Active Record model without interacting with a real database resource. For some people this breaks a rule about what a unit test should be. They then replace Active Record with something like the repository pattern. For people like myself, we just shrug our shoulders and use the database, and still call it unit testing. Sure, my tests arenβt as fast as they might otherwise be, but Iβm still gaining all the other benefits of unit tests over higher-level tests.
On the front-end... I think your use of the word simple is important. People donβt believe that unit testing UI code is simple. In my opinion, thatβs why they donβt do it. And since I know that Iβm having a lot of success with unit testing on the front-end, Iβm trying to share that knowledge with others.
I'm in the group of people who think doing unit testing in frontend isn't simple π
One of the reasons I think people feel that way is that it isn't obvious what to unit test in frontend world. Do we test styles? Do we test structure of HTML? Of course we should be testing JS functions but what about event handlers? Probably we've been doing it wrong.
And even though your article answers those questions, doing unit tests in the way you mentioned isn't as easy as frontend devs would like/hope.
Then I hope to see your content about this topic π
BTW, I wasn't aware of the DHH, Fowler, and Beck video. Thanks for sharing ππ½