How to access and test an internal (non-exports) function in a node.js module?

I’m trying to figure out on how to test internal (i.e. not exported) functions in nodejs (preferably with mocha or jasmine). And i have no idea! Let say I have a module like that: function exported(i) { return notExported(i) + 1; } function notExported(i) { return i*2; } exports.exported = exported; And the following test … Read more

In mocha testing while calling asynchronous function how to avoid the timeout Error: timeout of 2000ms exceeded

In my node application I’m using mocha to test my code. While calling many asynchronous functions using mocha, I’m getting timeout error (Error: timeout of 2000ms exceeded.). How can I resolve this? var module = require(‘../lib/myModule’); var should = require(‘chai’).should(); describe(‘Testing Module’, function() { it(‘Save Data’, function(done) { this.timeout(15000); var data = { a: ‘aa’, … Read more