DEV Community

Ririio
Ririio

Posted on

Working with Jest Framework

Which testing framework/tools did you choose? Why did you choose them? Provide links to each tool and briefly introduce them.
How did you set them up in your project? Be detailed so that other developers could read your blog and get some idea how to do the same.
What did you learn while writing your test cases? Did you have any "aha!" moments or get stuck?
Did your tests uncover any interesting bugs or edge cases?
What did you learn from this process? Had you ever done testing before? Do you think you'll do testing on projects in the future?

Jest Framework

For this week's lab, I decided to use Jest for testing my repository. I decided to use jest instead of mocha (a more established framework), due to how you can easily gain a report regarding how much of my files is being covered using the "coverage" option.

Bugs

There was only a single bug I found while testing, and it's merely the way that the MarkDown's syntax for a heading includes a "#" before the phrase that wants to be converted into a title. My code uses the syntax where there is a "#" from before and after the phrase, which causes it to not work as intended.

Learning Experience

Testing was covered a few semesters back for one of my web courses, and I never understood their importance. I mean if you're going to write your code, why bother testing them if you know it's already working as intended? However, learning through what test is actually about, and realizing that sure I write my code, and sure that I'm 99.9% sure that it works as intended, but it doesn't mean that it will always work correctly in the future. What I remember from the lecture is that regardless of how perfect your code is currently, it doesn't meant that it will stay the same when it's being updated.

What took me a while to understand is how to find the right value for the matchers. I first thougt to myself that adding the entire output is the best choice of action, but I then realized that it's very inconsistent. Therefore, I decided to use ReGex, and it made my life much easier.

The one I'm stuck on, and still is, is figuring out how to test a funciton that does not return any values nor contains functions within it.

Realizing how important it is to write a test, I will make sure that any future projects I create will include not just eslint, prettier, but also a test to ensure that my code works as greatly as possible

Top comments (0)