3

Angular-phonecatチュートリアルに続いて、scenario.jsのステップ7でbrowser()オブジェクトとbinding()オブジェクトが使用されますが、これらを使用してアプリケーションをテストしようとすると、testacularを実行すると次のようになります。

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

また、Intellij Idealは次のように述べています:未解決の関数またはメソッドbrowser()。ここで何が欠けていますか?

ここにチュートリアルのコードスニペットがあります:'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');
    });
  });
});
4

2 に答える 2

4

それはangular-scenario.js内で定義されています

于 2012-12-06T23:25:03.283 に答える
0

//スペックファイル

'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)
于 2014-12-18T04:59:52.850 に答える