Skip to content

How to mock getView() available in the controller #2

@Abi1210

Description

@Abi1210

I am creating a new controller in controller.js:
var newController=Alloy.createController('index').getView();

In test file (Controller_Spec.js) addded the following to mock getView
var dealerControllerMock = {
getView: function(){}
};
beforeEach(function() {
MockRequire = require('../../ti-unit/mockrequire');
MockRequire.addMock('getView', dealerControllerMock);
controllerUnderTest = require('../../app/controllers/index');
});

but it is not working. I am getting the following error while running the npm test:
TypeError: Cannot read property 'getView' of undefined

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions