I am writing tests with two collections which are client-side only. When calling restore and stub again after inserting, the first collection that was stubbed will be emptied, while the second will not. Please see this snippet:
let Collection1 = new Mongo.Collection(null);
let Collection2 = new Mongo.Collection(null);
StubCollections.stub([Collection1, Collection2]);
Collection1.insert({a: "a"});
Collection2.insert({b: "b"});
StubCollections.restore();
StubCollections.stub([Collection1, Collection2]);
Collection1.insert({c: "c"});
Collection2.insert({d: "d"});
console.log(Collection1.find().fetch()); //[{c: "c"}]
console.log(Collection2.find().fetch()); //[{b: "b", d: "d"}]
I am writing tests with two collections which are client-side only. When calling
restore
andstub
again after inserting, the first collection that was stubbed will be emptied, while the second will not. Please see this snippet:Same happens when using
seperatly