DEV Community

Cover image for Only 3As to writing your first test!
Mwenedata Apotre
Mwenedata Apotre

Posted on • Edited on

Only 3As to writing your first test!

I've been developing web applications for so long but I always looked back when it came to testing and this has many reasons.
And let me elaborate:

My Code works why bother test?
I usually couldn't wrap my head around why I needed to write code to test something that I am using and is working perfectly fine. And I'm sure many of other junior developers also have the same thinking but we'll explore why we need to test.

Testing is very hard and is for Senior Developers

Well this is a real case and I too, used to think like that and this is because I saw many job postings requiring testers to be highly experienced individuals. Well testing sometimes does require core understanding of the tools you are using to test and the app you are testing with the libraries used to develop it but in the end I just found out it's not that hard and is very easy to implement the tests.

There exist many other reasons to why I avoided testing but the above are one of the main.

So what is testing all about?

Testing in software development refers to the process of writing code to test either some parts of the software , their integration or the software as a whole or using the software directly and testing every feature to see if it works following the flow.

With testing React Apps testing is very very simple just the 3As

3As

  • Arrange : here you just render components and provide the props required using code. (Mainly libraries are there to help with you).
  • Act : Acting is the most important step in testing because this is where you mimic the user's action using code to then expect certain things to happen or not.
  • Assert : The last and mainly the intended part of testing is assertion , here you expect something to happen given the actions you deployed in the second step like the button being disabled the state changing etc...

So far What I've seen is that testing is not actually about coding but setting the right priorities and trying to perfectly mimic the user's action and then writing codes just depend on the library being used and doesn't matter that much as long as you understand the concepts and patterns.

This was part one of this series next time time I'll be talking about types of testing and how to get started. Like and follow for more!

Top comments (0)