From the course: React.js Essential Training

Unlock the full course today

Join today to access over 22,300 courses taught by industry experts or purchase this course individually.

Testing small functions with Jest

Testing small functions with Jest - React.js Tutorial

From the course: React.js Essential Training

Start my 1-month free trial

Testing small functions with Jest

- [Instructor] We can start to think about testing with a small example here. So inside of our source folder we want to create two different files. The first is called functions.js, and the second will be called functions.test.js. So we want to think about our functions file as being the place where our code will be written. And then our NPM test command is going to run any test that are part of this file. Create React App already has just configured. So all we need to do is start writing tests. So we're going to write a test using the test function and then the test function is going to have a name as its first argument. So we're going to keep it real simple here. We'll just say multiplies by two. And then it's also going to take in this callback function. So this callback function is going to have another function inside of it called expect. Okay. So the next thing we want to do is let's open up our functions.js file.…

Contents