4

If this test:

'use strict'

describe('application', function() {
    it('should login', function() {
        browser().navigateTo('/');
        expect('111').toBe('111');
    });
});

includes the "browser" line, the result is:

Chrome 26.0 (Windows) application should login FAILED
    ReferenceError: browser is not defined
        at null.<anonymous> (...../test/js/e2e/tests/test.js:6:9)
Chrome 26.0 (Windows): Executed 1 of 1 (1 FAILED) (0.359 secs / 0.004 secs)

but without this line the test succeeds.

People suggest to include angular-scenario.js, but this breaks tests

expect('111').toBe('222');

is evaluated as true.

What to do?

Paul
  • 25,812
  • 38
  • 124
  • 247

2 Answers2

7

You need to have your app's server running along with the karma runner. So with Node.js:

node app.js

Also, make sure you change the urlRoot property in your karma config so it doesn't conflict with your app's and yes you need angular-scenario.js

files = [
  ANGULAR_SCENARIO,
  ANGULAR_SCENARIO_ADAPTER,
  'test/**/*_spec.js'
];

urlRoot = '/__karma/';

proxies = {
  '/' : 'http://localhost:3000/'
};
Corey C
  • 124
  • 1
  • 4
0

I've run into this problem too. I believe you can only call browser() inside of a beforeEach(); Try this:

'use strict'

describe('application', function() {

    beforeEach(function(){
        browser().navigateTo('/');
    });

    it('should login', function() {
        expect('111').toBe('111');
    });

});
Shadowedged
  • 296
  • 1
  • 6