Mocking all objects on your controller's $ - aca-mobile/ti-unit GitHub Wiki

Typically, your controller contains a lot of references to objects and properties in it's view, which are referenced on $:

function onButtonClick() {
    UserManager.setUserName($.username.getValue());
    $.someLabel.text = 'anotherValue';
}

Writing a mock for $ can become quite some work, unless ... you generate them.

beforeEach(function () {
   // generate the mock
   $ = require('tiunit/mockcontroller').createControllerMock('../app/controllers/authenticate.js');
   
   MockRequire.addMock('user.manager', userManagerMock);
   controllerUnderTest = require('../app/controllers/authenticate');
});