Step 1 : Install node package manager
Step 2 : Create your project folder Example : f:\mocha_Chai
Step 3: Open command prompt
Step 4: Go to your project root directory
Step 5: Install package.json file. For installing package.json write command as below :- npm init Press enter at the end of all field. Note : Enter information like package.json contains.
Step 6: Install mocha in your project, go to your project root directory and wirte command npm install mocha
Note: To install mocha globally write command
npm install -g mocha
This is not depend upon project root directory.You can install anywhere,it will work global for your system.
To check mocha globally install, write command
mocha -V
Step 7: Install Chai in your project, go to your project root directory and wirte command npm install chai
Step 8: Create one test folder in your project Example : f:\mocha_Chai\test
Step 9: Create one test.js file in test folder.it will contain test cases. Example : f:\mocha_Chai\test\test.js code in test.js file
var expect = require('chai').expect; //add chai
describe('A basic test',function(){
it('Should pass when every thing is ok',function(){
expect(true).to.be.true;
});
});
Step 10: To run test cases, go to your project root directory and write command npm test