Skip to content

Testing node js applications using Mocha framework. Use of it() to create and write test cases.

Notifications You must be signed in to change notification settings

patilankita79/BasicTestingUsingMocha

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 

Repository files navigation

Basic Node JS App Testing Using Mocha

Adding automatic testing in node js applications using Mocha framework. Simple two functions are demonstrated to get started with testing using mocha framework. One function is to add numbers and other function squares a number. Test cases are written which performs testing to check whether the function works as expected or not. it() function is used.


Install mocha

npm install mocha --save-dev

I have written test cases in a files which ends with test.js. So In package.json following changes are made. In package.json, under "scripts", write "test": "mocha **/*test.js"
  "scripts": {
    "test": "mocha **/*.test.js"
  }

Running tests

npm test

Test cases to check addition of two numbers, sqaure of a number.

Passing test case


Failing test case


About

Testing node js applications using Mocha framework. Use of it() to create and write test cases.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published