【发布时间】: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