I installed jsmockito and jshamcrest as separate npm packages, and I found that jshamcrest matchers weren't working when verifying mocks. Matchers were working perfectly fine in other assertions, however.
After some debugging, I figured that the problem was that I had two conflicting versions of jshamcrest: v0.7, which I installed, and v0.6.7, which jsmockito installs as dependency. When jsmockito first loads, it creates a global JsHamcrest variable which points to it's private version of JsHamcrest (0.6.7). When my code later requires jshamcrest, the newer version is loaded, so when I refer to matchers, they are from a different library than that jsmockito is using, and therefore the objects are not recognized as matchers, and not used.
I solved the problem creating a small utility module that loads both libraries and replaces the global library:
var jshamcrest = require('jshamcrest').JsHamcrest;
var jsmockito = require("jsmockito").JsMockito;
global.JsHamcrest = jshamcrest;
jsmockito.Integration.importTo(global);
Perhaps the jsmockito module could avoid polluting the global namespace, or relax the version number declared for the dependency (currently set to match exactly 0.6.7)
I installed jsmockito and jshamcrest as separate npm packages, and I found that jshamcrest matchers weren't working when verifying mocks. Matchers were working perfectly fine in other assertions, however.
After some debugging, I figured that the problem was that I had two conflicting versions of jshamcrest: v0.7, which I installed, and v0.6.7, which jsmockito installs as dependency. When jsmockito first loads, it creates a global JsHamcrest variable which points to it's private version of JsHamcrest (0.6.7). When my code later requires jshamcrest, the newer version is loaded, so when I refer to matchers, they are from a different library than that jsmockito is using, and therefore the objects are not recognized as matchers, and not used.
I solved the problem creating a small utility module that loads both libraries and replaces the global library:
Perhaps the jsmockito module could avoid polluting the global namespace, or relax the version number declared for the dependency (currently set to match exactly 0.6.7)