DEV Community

loading...

#4 Introduction to Mocha testing

rittwickbhabak profile image Rittwick Bhabak ・1 min read

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

Discussion (0)

pic
Editor guide