3

Following the Angular-phonecat tutorial, step-7 in the scenario.js a browser() and binding() objects are used but, when I tried to use them to test my application, running testacular says:

ReferenceError: browser is not defined
        at null.<anonymous> 

Also Intellij Ideal says : unresolved function or method browser(). What am I missing here ?

here the code snippet from the tutorial: 'use strict';

/* http://docs.angularjs.org/guide/dev_guide.e2e-testing */

describe('PhoneCat App', function() {

  it('should redirect index.html to index.html#/phones', function() {
    browser().navigateTo('../../app/index.html');
    expect(browser().location().url()).toBe('/phones');
  });


  describe('Phone list view', function() {

    beforeEach(function() {
      browser().navigateTo('../../app/index.html#/phones'); //<---  browser() object is not defined !!! 
    });


    it('should filter the phone list as user types into the search box', function() {
      expect(repeater('.phones li').count()).toBe(20);

      input('query').enter('nexus');
      expect(repeater('.phones li').count()).toBe(1);

      input('query').enter('motorola');
      expect(repeater('.phones li').count()).toBe(8);
    });


    it('should be possible to control phone order via the drop down select box', function() {
      input('query').enter('tablet'); //let's narrow the dataset to make the test assertions shorter

      expect(repeater('.phones li', 'Phone List').column('phone.name')).
          toEqual(["Motorola XOOM\u2122 with Wi-Fi",
                   "MOTOROLA XOOM\u2122"]);

      select('orderProp').option('Alphabetical');

      expect(repeater('.phones li', 'Phone List').column('phone.name')).
          toEqual(["MOTOROLA XOOM\u2122",
                   "Motorola XOOM\u2122 with Wi-Fi"]);
    });


    it('should render phone specific links', function() {
      input('query').enter('nexus');
      element('.phones li a').click();
      expect(browser().location().url()).toBe('/phones/nexus-s');
    });
  });


  describe('Phone detail view', function() {

    beforeEach(function() {
      browser().navigateTo('../../app/index.html#/phones/nexus-s');
    });


    it('should display placeholder page with phoneId', function() {
      expect(binding('phoneId')).toBe('nexus-s');
    });
  });
});
Adelin
  • 18,144
  • 26
  • 115
  • 175
  • 1
    how are you running your tests? just in case e2e tests have their own config file and are run like this `testacular start testacular-e2e.conf.js`. Here's how the conf file should look like https://github.com/angular/angular-seed/blob/master/config/testacular-e2e.conf.js – jaime Dec 07 '12 at 00:52
  • This is a very related question: http://stackoverflow.com/questions/13173719/is-it-possible-to-mix-testacular-with-angular-scenario – Adelin Dec 10 '12 at 07:15

2 Answers2

4

It's defined within angular-scenario.js

Ryan O'Neill
  • 3,727
  • 22
  • 27
  • testacular behaves very strange when I include the angular-scenario.js – Adelin Dec 06 '12 at 23:35
  • 1
    Chrome 22.0: Executed 0 of 0 SUCCESS no test is executed, when I remove angular-scenario.js every goes OK ? any suggestions ? – Adelin Dec 06 '12 at 23:36
  • 1
    I'd recommend seeing if you can get the [angular-seed](https://github.com/angular/angular-seed/) project working first. You should be able to run node scripts/web-server.js & and then testacular start config/testacular-e2e.conf.js The runner.html file and the testacular-e2e.conf.js files should get you at least farther along. – Ryan O'Neill Dec 07 '12 at 00:10
0

//Spec file

'use strict';
describe('demoApp', function() {
it('should redirect node_list.html to node_list.html#/menu', function() {
browser().navigateTo('/node_list.html');
expect(browser().location().url()).toBe('/menu');
  });

describe('menu_view', function() {
beforeEach(function() {
  browser().navigateTo('/node_list.html#/menu'); 
});
});
});

Error:
Chrome 39.0.2171 (Linux) demoApp should redirect node_list.html to node_list.html#/menu FAILED
ReferenceError: browser is not defined at Object.<anonymous> (/test/viewpage.js:5:5)
Siva
  • 9
  • 1