The mock method lets you pass in mocks to be used for a given modules dependency. The first argument is the module name, the second argument is the mock itself. For multiple mocks you can pass an object, the objects key will be the path and the corresponding value will be used as the mock.

var injector =newSquire();

// Key value mocking.

injector.mock(dependencyName, mockForDependency);

// You can pass an object literal as well.

injector.mock(dependencyNameAndMock);

var injector =newSquire();

injector.mock('CrazyCalculatorDependency',{

sin:10

})

.require(['utilities/Calculator'],function(Calculator){

// The Calculators dependency 'CrazyCalculatorDependency' has been mocked to

Run generates a function that will receive a done callback and execute it after your test function is complete. Particularly useful for frameworks where asynchrony is handled with a callback. Here is an example with Mocha.js. Jasmine can offer this callback approach using Jasmin.Async.

Often times AMD modules return constructor functions which means that mocking such a class would end up having to create a function that returns a function that returns your mocked instance. Squire.js eases that pain by wrapping up your instance for you.