When it comes to unit testing, I've created a mock object that I use in my test files like this:
var mockObject = {
mockMethod1 : function() {return true},
mockMethod2 : function() {return true}
};
beforeEach(module('myModule') , function ($provide) {
$provide.value('realObject',mockObject);
});
From what I understand, any references to 'realObject' will actually use 'mockObject' during testing.
However, I'm facing an issue where I have multiple JavaScript files for testing and I don't want to redefine 'mockObject' in each file or maintain it in more places than necessary.
Is there a way to move 'mockObject' to a separate file that can be included in karma.conf.js so that it's available for injection into all of my test files? I'm thinking something similar to how you inject $rootScope.