require('../../model/account');
sinon = require('sinon'),
mongoose = require('mongoose'),
accountStub = sinon.stub(mongoose.model('Account').prototype, 'findById');
controller = require('../../controllers/account');
describe('Account Controller', function() {
beforeEach(function(){
accountStub.withArgs('abc123')
.returns({'_id': 'abc123', 'name': 'Account Name'});
});
describe('account id supplied in querystring', function(){
it('should retrieve acconunt and return to view', function(){
var req = {query: {accountId: 'abc123'}};
var res = {render: function(){}};
controller.index(req, res);
//asserts would go here
});
});My problem is that I am getting the following exception when running mocha
TypeError: Attempted to wrap undefined property findById as function
What am I doing wrong?