lundi 27 juillet 2015

How to use Stub object with tinytest and meteorjs?

This weekend i tryed to test a package "A" from my meteor app. This package depends on another package "B" that defines all collections. So the package "B" expose all required collections.

The package "A" expose a main object that have some methods that use the collections exposed in "B".

I want to replace some collections by a code like this :

myCol = {
    "findOne": return {_id: 1, "name": ben}
}

But it fails. This code is ok from tinytest.add code, but in the methods of the package "A", it still uses the original Collection variables. I've seen in the build folder that everything is re-written by the build system, so i wonder what is the best way to test my code without depending on those Collection variables. I have some ideas like storing those variables in a main object that has get/set methods. It might allow me to change everything when i do test.

Thanks for help

Aucun commentaire:

Enregistrer un commentaire