paint-brush
How to fix & hunt bugs the right way?by@arthur_guiot
151 reads

How to fix & hunt bugs the right way?

by Arthur GuiotOctober 22nd, 2017
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

<em>Sometimes, you're so excited about your next project that you keep adding features… Without noticing that you just broke all the system.</em>

Companies Mentioned

Mention Thumbnail
Mention Thumbnail
featured image - How to fix & hunt bugs the right way?
Arthur Guiot HackerNoon profile picture

Sometimes, you're so excited about your next project that you keep adding features… Without noticing that you just broke all the system.

Once you’re ready to publish, you just give a look at what you were building, and you see that it just doesn’t work 😤.

You try to hunt the bug 🐛, but when you open the console, no errors appear.

Now, you switch back and forth from your code to your browser, and you’re just trying to find where the bug could come from.

Because you can’t find the bug 🐛, you go in your terminal, and you just type

git log 

To get the latest working version in your git repo. And you reset your working directory

git reset --hard <commit>

The problem

Using this method, you're not productive, and you obviously 🙄 might in the future do the same mistake a reset your work again.

And, you’ll also loose all your new functionalities (even if they weren't working).

The solution

The solution is to test your code. If you test every part of your code, you simply can’t have break everything because you will have more hints to fix it (just knowing where it comes from is a big deal, believe me 😊).

But how to that?

Well, there are several frameworks out there, here is two of them:

Jest will be more useful in very big node projects because it has a lot of testing features, but for normal projects, it’s a bit over-killed. Facebook developed it to work very well with their environment, which means that even if it can’t do tests in the browser, it can use React to simulate real conditions. So, if you're using React or you’re working a huge node project, it will be a better choice 😊.

EyeJS is different, it doesn't target 🎯 the same people. It will work perfectly for almost any projects because it can do, as Jest, node-based test. And, it’s the only testing framework that has a real browser support, it means that in the same command, it will be able to run NodeJS tests and open your browser to run other automated tests.

Conclusion

They are both very different, and I think 🤔 you can be productive with both. You should definitely try them both and see which one helped you the most at hunting bugs 🐛.

Thank you ☺️ for taking the time to read this story.