Evan Cordulack

Setting Up JavaScript Unit Testing Tools Quickly

July 21, 2019

Install the packages we need (Mocha, Chai, Sinon, NYC)

npm install mocha --save-dev
npm install --save-dev chai
npm install --save-dev sinon
npm install --save-dev nyc

Put something like this line in package.json "test": "nyc mocha \"./js/**/*.test.js\"",

Once you add a test file, you can run your tests using this command: npm run test

Here is some test code you can put in a test file to confirm your tests are working:


describe('/src/ads.js', function() {
  describe('#someFunction()', function() {
    it('should return true', function() {
      assert.isTrue(true);
    });
  });
});```