These are chat archives for Automattic/mongoose

23rd
Nov 2015
hellboy81
@hellboy81
Nov 23 2015 07:44

@rapitkan @uptownhr @nottinhill @vkarpov15 I am trying to test statics for mongoose model in module. Model is created bases on schema:

var mongoose = require('mongoose'),
    Schema = mongoose.Schema

var MyModelSchema = new Schema (...)

// This static method should be unit tested
MyModelSchema.statics.myMethod = function(...){...}

How can I do it correctly?

  • Should I stub require('mongoose') dependency in my spec init?
Pablo Vilas
@pablovilas
Nov 23 2015 16:53
Hello everyone. Is there an upto date cache plugin or technic for mongoose caching?
Alex J Burke
@alexjeffburke
Nov 23 2015 20:35
Hi there - I know this is an unconventional thing to do, but I'm hoping you might be able to help me anyway. I'm trying to get some mocking of mongo but I've hit a bit of a wall - I can see calls heading into a method, in this case save() attached to a model at which point my code just hangs. Having looked in the internals I think what I should see is something call doQueue() to actually execute the command, but I just lose track of what's going on after the pre hooks are called during validation. Can anyone point me to what is supposed to trigger these deferred calls? I've tried to trap in an appropriate place when using all the real drivers but the stack starts from a timer which comes up through a mystery codepath and eventually triggers the overall callback. Would gladly welcome any hints! Thanks