DEV Community

Sergio Romeu
Sergio Romeu

Posted on

Why you should test both frontend and backend.

Hey! This is my first post in here, my name is Sergio and I am a web dev. Anyways, I will try to keep it clean and nice 😆

So... We all have been there, you have finally finished that assignment that was driving you crazy, you see the light at the end of the tunnel, but suddenly you remember the bad part of programming, TESTING.

Testing GIF

There are difficult opinions about it in the dev community, it is praised by some and hated by others. However, even if you are in one or another side, at the end of the day you know it is a necessary step to ensure our application is running and is functioning correctly.

( Yes, yes, we sometimes run out of time and there is no way tests are possible, we all know that feeling unfortunately... 😞 )

This topic came to my mind as I was browsing StackOverflow in search of questions to answer and help some people out, and this one caught my attention, it came as following:

"Do both: Front-end and Backend Unit tests?"

Basically, OP was asking if both front and back-end testing is necessary.

This is a common discussion topic, there are web devs that do back-end testing, others that do front-end testing, and others that do both, it mostly depends in what area you are developing and what are your company's policy (hello there fellow freelancers!).

However, as a dev, I think that we get more benefits from doing testing than by not doing so.

First of all, you make sure that your piece of work is working as you expected, and that there are no flaws on it. You can even try to test by doing mocks with different types of data, and try to get the result, this could be achievable with Postman by doing simple JavaScript tests.

Testing cats

There is a cool feature in Postman, it is called Runner, it lets you write and run the tests, ALL AT ONCE. You can see if the tests have passed the requirements you have stipulated before, by checking the body and code of the response. 😎

Furthermore, if you are using Laravel/Lumen to create your API you can take advantage of their own unit tests. If you are able to perform both Postman and unit testing and all your test turn out well, congratulations you have got a bulletproof API!

After you have made sure that your API is good to go, you can take a step ahead and test your front-end, this is basically doing mockup tests just by yourself or doing it the cool way with Selenium 🤓

Selenium is good to go to test the functionalities of your web app, the tests can be written in languages like Java, PHP, C#, etc. It performs end to end testing across various browsers and platforms like Windows, Mac, and Linux.

Selenium testing

So once you are both done with your front and back-end, and you made sure that all your tests have passed, you are ready to go and deploy the app!

What are your thoughts about testing? Do you like to do it or are you one of those devs that hate it? Tell me your thoughts below.

Until the next post! Happy coding! Sergio.
🥰 🤓

(If there is anything that bothered you while reading, tell me so I can improve it in my next posts, thank you very much!)

Latest comments (0)