I feel very confused, how to unit test involves mongodb in mocha, I still can not successfully call the save function with no exception is thrown.
I try to use the most simple example for testing and found that there are still problems.Here is my code .
var assert = require("assert")
var mongoose = require('mongoose');
mongoose.connect('mongodb://localhost/dev', function(err){
if(err) throw err
});
describe('increment Id', function(){
describe('increment', function(){
it('should has increment', function(){
var Cat = mongoose.model('Cat', { name: String });
var kitty = new Cat({ name: 'Zildjian' });
kitty.save(function (err) {
if (err) throw err
console.log('meow');
});
})
})
})
This code does not throw an exception, but there is no data updated or created in the mongodb .
> show collections
pieces
sequences
system.indexes