Skip to content

Instantly share code, notes, and snippets.

@passandscore
Created April 25, 2021 01:26
Show Gist options
  • Save passandscore/58843750fe5fd0f8d145e08f155900bb to your computer and use it in GitHub Desktop.
Save passandscore/58843750fe5fd0f8d145e08f155900bb to your computer and use it in GitHub Desktop.
Unit Testing Template (Mocha & Chai)
//Unit testing template
//Language: JavaScript
//Packages: Mocha, Chai
//Javascript file
module.exports = subSum;
//JavaScript test file
const { expect, assert, should } = require('chai');
const subSum = require('./subSum');
should();
describe('Test subSum Function', () => {
it('Should retuen NaN if the first element is not an array', () => {
assert.equal(isNaN(subSum([10, 20, 30, 40, 50], 3, 300)), isNaN(1))
});
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment