Schema hasn't been registered for model "categories". Use mongoose.model(name, schema)
<p>When i called my function in controller through postman,it worked fine and i got results but when i wrote a test case for the same function it is saying the error as</p>

<pre><code>MissingSchemaError: Schema hasn't been registered for model "categories".
Use mongoose.model(name, schema)
</code></pre>

<p>I was completely confused about these because how come a function that is working well go wrong with test case.Can any one suggest help please.
My test.js,</p>

<pre><code>      var server = require('../modules/categories/model/categories.server.model');
var chai = require('chai');
var chaiHttp = require('chai-http');

var should = chai.should();
var mongoose = require('mongoose');
chai.use(chaiHttp);

describe('Blobs', function() {
  it('should list ALL blobs on /getcategories GET');
});

it('should list ALL categories on /getcategories', function(done) {
  chai.request(server)
    .get('getcategories')
    .end(function(err, res){
      res.should.have.status(200);
      done();
    });
});
</code></pre>

<p>My Routes,</p>

<pre><code>     */
var categories = require('../categories/controller/categories.server.controller');
var model = require('../categories/model/categories.server.model');
var passport = require('passport');
module.exports = function (app) {
  // User Routes

  app.use(function (req, res, next) {
  // Setting up the users password api
  app.route('/api/auth/insertcategory').post(categories.insertcategory);
  app.route('/api/auth/getcategoriesbycreatedid/:id').get(categories.getcategoriesbycreatedid);
  app.route('/api/auth/getcategories').get(categories.getcategories);
});
</code></pre>

<p>Can some one please suggest help.</p>