Mocha.js: how to test consequent save and delete with mongoose


Testing framework: mocha I want to test saving and then deleting created document in mongodb (with mongoose)

Code that actually do this :

item = new Item(), data){
   // if no errors test passed, then I need to test removing that item 

How should I describe the test?

I want to have separate tests results for save and remove in output.


Problem courtesy of: WHITECOLOR


var User = require('../../models/user');

describe('User', function(){
  describe('#save()', function(){
    it('should save without error', function(done){
      var user = new User({        username    : 'Luna'
        , email     : ''
        , password  : 'asdf123'
        if (err) throw err;
Solution courtesy of: chovy


There is currently no discussion for this recipe.

This recipe can be found in it's original form on Stack Over Flow.