【问题标题】:Ordering of Angular e2e describe and it blocksAngular e2e 描述的排序和它的阻塞
【发布时间】:2013-05-31 15:20:01
【问题描述】:

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

describe() 块内,为什么it() 块总是任何嵌套的describe() 块之后执行,无论它们在测试中的顺序如何?

例如:

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 页面上” 是有道理的。

【问题讨论】:

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


    【解决方案1】:

    我同意。

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

    【讨论】:

      猜你喜欢
      • 2021-06-19
      • 1970-01-01
      • 2011-08-02
      • 1970-01-01
      • 1970-01-01
      • 2019-11-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多