Best Practices for Data Model Testing?


I’m new to testing and trying to understand what the best option is for testing some of my code.

Specifically, I have some code observing specific collections and doing some transformations on that data before updating other collections.

How and what do you use for this kind of activity? Do you setup a full testing MongoDB instance and populate/validate against that data? Do you use a mock API to simulate the data layer?

Are there any specific packages? I noticed Jasmine comes with a MeteorStubs package, does that include data model stubs, and if so how are they used properly?


I would recommend that you use sanjo:jasmine Server Integration mode. In this mode you test your app in a clean running state. Just extract the observer handlers into named functions so you can test them separately. I hope that’s enough info for you to get started. Feel free to ask further questions.


Regarding MeteorStubs. You can find the source here:

Here you find instructions of how to use them in sanjo:jasmine: