Testing is very important in software development. Testing is a process, to evaluate the functionality of a software application with an intent to find whether the developed software met the specified requirements or not and to identify the defects to ensure that the product is defect-free in order to produce the quality product. I will be informing you on how to write basic tests using Jest. Jest is an open JavaScript testing library from Facebook. Its slogan is "Delightful JavaScript Testing". Jest can be used to test any JavaScript library. Now let’s practice! This testing thing really is not that difficult, but it quite new. The only way to get comfortable with it is to spend some time doing it. is To test with Jest the first thing you have to do is install it. You can either install it using npm or yarn. If you want to use npm you will need the latest version of node and npm. Go to the official website, click on download node js and npm and follow the instructions. npm If you want to use yarn, Go to the official website, pick your operating system and follow the instructions below. yarn After installing npm or yarn, in your command line run: npm init or yarn init This is to create a package.json file which holds various metadata relevant to the project. Based on the project, npm will ask you a few questions and will create a basic configuration file with a short description for each option. After that run: npm install --save-dev jest or yarn add --dev jest to install Jest into the project Go to your package.json file and add the following to the first section of the file { : { : } } "scripts" "test" "jest" Special Note on using ES6 import statements with Jest The current version of Jest does not recognize the import statement. In order for you to be able to use ES6 modules for this testing with Jest you may do the following: 1. Install the @babel/preset-env package npm i -D @babel/preset-env Create a .babelrc file in the project’s root with the following lines of code: { : [ ] } "presets" "@babel/preset-env" This will allow you to use import statements. Note that in the Jest docs a similar instruction is laid out . here After installing jest, open up your project folder in your preferred code editor. Create a file called and write your function in it. capitalize.js capitalize = { string.charAt( ).toUpperCase() + string.slice( ); }; .exports = capitalize; .exports = capitalize; const ( ) => string return 0 1 module module After that create another file called which will contain the tests for the function. capitalize.test.js capitalize = ( ); test( , () => { expect(capitalize( )).toBe( ); }); const require './capitalize' 'returns the first letter capitalized' 'john' 'John' Finally, run or and Jest will print this message: yarn test npm run test PASS capitalize/capitalize.test.js ✓ returns the first letter capitalized ( ms) Test Suites: passed, total Tests: passed, total Snapshots: total Time: s, estimated s Ran all test suites matching /capitalize.test.js/i. 2 1 1 1 1 0 1.086 2 Congratulations! You just successfully wrote your first test using Jest! Lastly, remember to always write tests for your software. It is very important.