hwillson / meteor-stub-collections

Stub out Meteor collections with in-memory local collections.
MIT License
24 stars 17 forks source link

Fix #14 - Using stubbed collections for publication tests #27

Closed coagmano closed 6 years ago

coagmano commented 6 years ago

I tried and failed to reproduces the issue in a new project. It is probably something specific about the packages in use or the order in which dependencies are resolved.

Instead I tried a simple fix that passes through the name to the collection constructor and instead sets connection: null in the options object. This failed the package tests because using the same name for subsequent tests meant the changes are persisted between stubs.

The solution then was to postfix the name with a random string. This now passes the package tests and my app's tests.


Using a stub-collection with johanbrook:meteor-publication-collector sometimes causes the error

Error: Can't publish a cursor from a collection without a name.

The simple fix for this is to create a localCollection with a name. To ensure that the stubbed collection doesn't connect to an existing local collection that was stubbed previously, we randomise the name.

hwillson commented 6 years ago

Awesome @coagmano, this looks great - thanks very much!