hwillson / meteor-stub-collections

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

Using stubbed collections for publication tests #14

Closed ebbe-brandstrup closed 6 years ago

ebbe-brandstrup commented 7 years ago

Hi,

I'm trying to use the johanbrook:meteor-publication-collector package for publication tests. I would like to use stubbed collections to have the tests run quicker.

The stacktrace of the error I get is:

Can't publish a cursor from a collection without a name. at [object Object].LocalCollection.Cursor._publishCursor (packages/minimongo.js:265:11) at packages/johanbrook:publication-collector/publication-collector.js:49:20 at Array.map (native) at PublicationCollector.collect (packages/johanbrook:publication-collector/publication-collector.js:44:47)

It seems to me that the error occurs because this package creates an in-memory (minimongo) collection to replace the real collection by creating a new Meteor collection without a name (null).

I am hoping you have some insight to share?

Thanks!

ebbe-brandstrup commented 7 years ago

Heads up - the closed issue in the johanbrook:meteor-publication-collector package where I mentioned this issue in did not resolve my problem.

hwillson commented 7 years ago

Hi @ebbe-brandstrup - thanks for reporting this. Any chance you could put together a small (runnable) repro showing the exact problem? I'll then use that repro to troubleshoot and fix the issue (I'm a bit swamped right now, so providing a runnable repro would definitely help get a fix for this in faster). Also - I love PR's if you're interested in addressing this issue yourself. Thanks again!

hwillson commented 6 years ago

I'll close this for now, but if you're able to supply a small, runnable reproduction that demonstrates this, I'll take a look. Thanks!

coagmano commented 6 years ago

I've just run into this issue as well. I was unable to make a simple reproduction, but was able to make a fix.

I've added a PR with that fix in #27

hwillson commented 6 years ago

Thanks @coagmano - I've merged #27 and published hwillson:stub-collections version 1.0.7. Let me know if you notice any issues. Thanks again!

coagmano commented 6 years ago

just realised that this is more likely to break tests that didn't have this issue before because the collections object returned from PublicationCollector will have the randomised names, where previously folks could just reference the original collection's name.

Working on a better solution that should also fix #24

coagmano commented 6 years ago

Okay opened a new PR with the changes. Sorry for the mixup!

hwillson commented 6 years ago

No problem @coagmano - thanks for the fix. Published as 1.0.8.