7

浏览 Angular js教程,我不明白 jasmine 测试中的中继器(功能?)来自哪里。这是茉莉花还是角结构?

该页面在元素中确实有一个 ng-repeat 属性<li>- 但我看不出它如何转化为测试中对“中继器”的引用

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

    //where does  'repeater' below come from?
    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"]);
    });
4

1 回答 1

7

repeater不是 Jasmine 构造,它是 AngularJS e2e 场景测试器的概念。

repeater函数在 AngularJS e2e 场景运行器使用的 DSL 中定义,其定义可以在这里看到: https ://github.com/angular/angular.js/blob/master/src/ngScenario/dsl.js#L249相应的文档位于:http ://docs.angularjs.org/guide/dev_guide.e2e-testing

应该注意的是,即使 AngularJS 使用 Jasmine 语法进行端到端测试,那些 e2e 测试也不是Jasmine 测试,它们只是碰巧使用了非常相似的语法。AngularJS 运行ngScenario器的目的是在浏览器中执行端到端测试,并使用与浏览器环境(DOM、位置等)紧密相关的匹配器。Jasmine 更专注于单元测试,并为 JavaScript 对象提供匹配器。

The mentioned repeater is just a way of counting DOM object given a jQuery selector and it is true that is usually used to count DOM element produced by the ngRepeat directive.

于 2012-11-03T20:35:27.753 回答