Question

Here is what I have tried:

$ git clone https://github.com/angular/angular-seed my_project && cd my_project
$ rm -rf app update_angular.js test/e2e/scenarios.js
$ touch test/e2e/scenarios.js

I then pasted code from AngularJS's official ngMock.$httpBackend docs into:

test/e2e/scenarios.js

'use strict';                               // Line 1

function MyController($scope, $http) {...}  // Lines 3-22

describe('MyController', function() {...}   // Lines 24-87

Error

Unfortunately when I run the tests using config/karma-e2e.conf, I get:

ReferenceError: inject is not defined at
                http://localhost:9876/base/test/e2e/scenarios.js?1387679134000:31
Was it helpful?

Solution

inject is defined in angular-mocks file, and is intended for unit tests only. If you're using Karma just add it to the files array.

e2e tests are on top of the browser, and run by angular-scenario. you can't inject any Angular components there.

BTW the Angular team are in the process of migrating their functional testing to protractor which is based on Selenium. I'd catch up with that instead of the angular-scenario testing framework. Protractor is a lot better.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top