I have a package (yeputons/meteor-smart-publish) which uses observeChanges
a lot, and I want to add a test (I use TinyTest right now) which allows me to ensure that all such observers are terminated in the end and no handle.stop()
was skipped.
The straightforward way is: add the 'Facts' package (which is Meteor-internal), subscribe to 'meteor_facts' and check for observe-handles
property of item with _id="mongo-livedata"
, which is not very safe because it's all undocumented and can be modified in any way in the future.
Is there any more documented way of checking such things?
Facts
package was built with a sole purpose to show some moving numbers in a dashboard of your admin interface.
Here is my proposed solution which is still hacky, but at least can be implemented w/o touching facts and subscriptions on the client:
You can monkey patch the constructors and stop methods of oplog-observe-driver and polling-driver classes. By wrapping them with a function that just calls the original but validates some state in your tests you can achieve your testing goals: