DEV Community

Rittwick Bhabak
Rittwick Bhabak

Posted on

#4 Introduction to Mocha testing

Mocha is a testing framework.
We use it to perform within our application
To make sure everything works correctly
First install Mocha npm install mocha --save
Keep the test script demo_test.js to a folder /test.
demo_test.js

const mocha = require('mocha');
const assert = require('assert');

describe('Some demo tests', function(){
    //Create tests
    it('adds two numbers together', function(){
        assert(2+3===5)
    })
})
Enter fullscreen mode Exit fullscreen mode

Set the test property to mocha in package.json
and run npm run test

Latest comments (0)