Skip to content

Instantly share code, notes, and snippets.

@bmorelli25
Created June 7, 2017 00:35
Show Gist options
  • Save bmorelli25/2d292f88d7341522a1e1c02dd1bb4136 to your computer and use it in GitHub Desktop.
Save bmorelli25/2d292f88d7341522a1e1c02dd1bb4136 to your computer and use it in GitHub Desktop.
How to test Node.js with Mocha
// Require the built in 'assertion' library
var assert = require('assert');
// Create a group of tests about Arrays
describe('Array', function() {
// Within our Array group, Create a group of tests for indexOf
describe('#indexOf()', function() {
// A string explanation of what we're testing
it('should return -1 when the value is not present', function(){
// Our actual test: -1 should equal indexOf(...)
assert.equal(-1, [1,2,3].indexOf(4));
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment