I think its called fixtures, however I tried using http://ift.tt/1WoyP0X which does not work at all and seems poorly written (specially the doc) to even respond if something is not right.
What I want is to have a file like a config which contains test datas.
myCollection = [
{ _id: 1, name: 'john'},
{ _id: 2, name: 'cena'}
]
once loaded, whenever I call a built in (ex: find, findOne) or customized (schema.statics.myFunction), it will return data based on that config file including the methods written on the schema level (schema.methods.myModelFunction).
myCollection.findOne({ _id: 1}, function (err, data) {
if (data) {
data.myModelFunction();
}
})
as can be seen, the mongoose should be able to treat the config file as if it is the database source and not affect the real database. is there a library for this that is already existing? thanks
P.S. I use sinon, mocha, mongoose-sinon, chai for my tests.
Aucun commentaire:
Enregistrer un commentaire