I'm running unit tests on a controller in an angular app. My test so far is:
describe('Controller', function () {
var scope, ctrl;
beforeEach(module('myApp'));
beforeEach(inject(function ($rootScope,
$controller) {
scope = $rootScope.$new();
ctrl = $controller('Controller', {
$scope: scope
});
}));
beforeEach(browser().navigateTo('/'));
it('should get you to the next page', function () {
scope.submit();
expect(browser().location().path()).toBe('/new')
});
});
with controller
var Controller = function ($scope, $location) {
$scope.submit = function () {
$location.path('/new');
}
}
However, when I run this I get the error browser is not defined
. What is going on here? Isn't this provided by Angular?
Edit: Even stranger, I'm getting the error that inject
is not defined.
Here's the config file:
basePath = '../';
framework = ["ng-scenario"];
files = [
ANGULAR_SCENARIO,
ANGULAR_SCENARIO_ADAPTER,
'http://code.jquery.com/jquery-1.9.1.min.js',
'https://ajax.googleapis.com/ajax/libs/angularjs/1.0.6/angular.min.js',
'../static/javascript/angular-mocks.js',
'../static/javascript/angular-scenario.js',
'../static/javascript/stripe.js',
'templates/static/avgrund.jquery.js',
'templates/static/chosen.jquery.js',
'templates/static/app.js',
'tests/E2E/tests.js'
];
urlRoot = '/_karma_/';
singleRun = true;
browsers = ['Chrome'];
junitReporter = {
outputFile: 'test-output.xml',
suite: 'e2e'
};