2013-05-31 18 views
1

我使用Karma在AngularJS中運行e2e測試。Angular 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頁上的」在別的之前。

回答

1

我同意。

解決方法是始終保持僅包含其他「描述塊」或僅包含「塊」的描述塊。這樣,訂單保持一致。