javascript - Angular e2e 描述的排序和它的阻塞

标签 javascript angularjs end-to-end karma-runner

我正在使用 Karma 在 AngularJS 中运行 e2e 测试。

describe() block 中,为什么 it() block 总是任何嵌套的 describe() block ,无论它们在测试中的顺序如何?

例如:

describe( 'Hello Page Nav Bar', function()
{
    it( 'should be on the hello page', function()
    {
        expect( browser().location().url() ).toBe( '/hello' );
    } );

    // ... many other it() blocks relating to 'Nav Bar' ...

    // Create nested describe specifically for menu items within the nav bar
    describe( 'Nav Bar Menu Items', function()
    {
        it( 'should have 12', function()
        {
            expect( element( '.menu-items div' ).count() ).toBe( 12 );
        } );

        // ... many other it() blocks relating to 'Nav Bar Menu Items' ...
    } );
});

最终将按以下顺序执行:

* Hello Page Nav Bar
   *  Nav Bar Menu Items
      *   should have 12
   * should be on the hello page

我想在其他任何事情之前测试“应该在 hello 页面上”是有道理的。

最佳答案

我同意。

解决方法是始终保持描述 block 仅包含其他“描述 block ”或仅包含“it block ”。这样,顺序就保持一致。

关于javascript - Angular e2e 描述的排序和它的阻塞,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16860668/

相关文章:

selenium - 守夜人 : Basic auth with access_key not working

javascript - Cloud Code object.save() 使用非常奇怪的 PUT 命令导致 'object not found'

javascript - 使用 JavaScript 的多读或多或少链接

javascript - AngularJS 模型逻辑放在哪里?

javascript - 在 AngularJs 1.x 和 Angular Js Material 1 中使用 ES/TS 语法的优点

testing - 如何将 Protractor 报告发送到使用 protractor-html-screenshot-reporter 生成的不同电子邮件

php - MongoDB,errmsg,异常 : couldn't compile code for: _map, PHP,命令,MapReduce

javascript - 如何使用 javascript 将变量的内容写入 <td>here</td> 的文本区域?

javascript - 通过更改对象属性使按钮禁用

angularjs - 如何使用 Protractor 更改计算机设备的日期和时间