DEV Community

Discussion on: Things I learned after writing tests for JS and HTML page

Collapse
 
shermayster profile image
Pavel Shermayster

Try to avoid testing implementation details, it’s better to focus on testing functionality.

In you case I would test result in UI, rather than “get item” function. In that case, you can make refactoring, change name of the function, transfer to different module, and tests will help you to validate that you didn’t break functionality of the code.

Then you testing implantation, you need to change your tests with your code, so it’s not very helpful.

Collapse
 
snowleo208 profile image
Yuki Cheung • Edited

Thanks for your reply!

I am still a beginner of testing and I found that it is hard to learn how to write good tests. You reply is extremely helpful. Thanks! :)