Skip to content

sangcnguyen/demo-mocha

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Background

What is Mocha?

Mocha is a JavaScript test framework running on node.js and the browser.

Mocha Logo

Made by TJ Holowaychuk creator of Express (by far the most popular node.js web framework), Mocha is TJ's answer to the problem of testing JavaScript.

Installation

Installation with npm globally:

$ npm install mocha -g

or as a development dependency for your project:

$ npm install --save-dev mocha

More info: http://mochajs.org/#installation

First test

Create Test Directory

In your project create a new /test directory to hold your tests:

$ mkdir test

Create test.js File

create a new file ./test/test.js in your text editor

Run Test

By typing the command mocha in your terminal the mocha command line program will look for a /test directory and run any .js files it contains:

$ mocha

or you can set up a test script in package.json:

 "scripts":{
     "test": "mocha"
   }

then run tests with:

$ npm test

About

An example of how to use mocha to write unit tests

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published