DEV Community

Jonathan Cohen
Jonathan Cohen

Posted on

Surely you Jest?

It's been a busy busy week for me. Somehow I'm managing the time to be able to try and learn new thing weekly. Honestly, I'm amazed...although I do wish there was more time in the day to try my hand at more things and carve out more time for myself. Alas, we do what we can with what we have and this week I started trying my hand and testing in JS with the jest framework.

Jest can be thought of as a testing framework that is designed to ensure correctness of any JS codebase. So far in my experience, I've been practicing with the keywords of describe, test, expect and to be. Since I'm in my early stages of working with this framework, I will only talk about the describe function today.

Describe()
-Takes in two arguments, a string of the name of the function and a function. The block of the describe function is usually home to the test function. In certain cases you can even have multiple test functions called within one describe block. Below is an example of how describe could be used.

describe("ten()", () => {

  });
Enter fullscreen mode Exit fullscreen mode

The describe function has a string as the first argument. The string is ten(). After this string is given to identify the name of the function we're testing, we now have to test it. Next week we'll combine this example with the test function and really start to see some cool things. Happy Coding.

Top comments (0)