Exploring Squire.js as a dependency loader for RequireJS. Testing in a standard web browser environment to run unit tests. Attempting to utilize store
to access my mocks, but struggling with preventing Squire from loading the actual module.
The usage of mock
functions smoothly:
define(['lib/squire'], function (squire) {
var injector = new squire();
injector
.mock('modules/dependency', {
run: function () {
console.log("fake dependency run");
}
})
.require(['modules/module-under-test'], function (module) {
module.run();
});
});
Console output:
module under test loaded module-under-test.js:2
module under test run module-under-test.js:5
fake module run module-test.js:8
However, encountering an issue when trying to use store
like so:
define(['lib/squire'], function (squire) {
var injector = new squire();
injector
.store('modules/dependency')
.require(['modules/module-under-test', 'mocks'], function (module, mocks) {
mocks.store["modules/dependency"] = {
run: function () {
console.log("fake dependency run");
}
};
module.run();
});
});
The actual module is being used and executed:
real dependency loaded dependency.js:2
module under test loaded module-under-test.js:2
module under test run module-under-test.js:5
real dependency run dependency.js:5
Squire documentation explicitly states that this should work fine. Using the latest versions of Squire.js from Github and RequireJS from requirejs.org. What could be the mistake on my end?