問題描述
我正在為 Web 應用程序實施量角器測試.我已經做了一些谷歌搜索,但我想出了 zip,我希望我創建的每個規范在瀏覽器運行該特定規范文件中的所有測試后關閉瀏覽器,然后繼續到下一個 -spec 文件,等等.我有諸如使用beforeAll"和afterAll"之類的東西,但 Jasmine 無法識別這些方法.朝著正確的方向前進會很棒!
I am implementing Protractor test for a web app. I have done some google searching but I have come up with zip, I want to every spec that I create to close the browser after it has ran all of the test in that specific spec file and then continue on to the next -spec file, etc. I've things such as using "beforeAll" and "afterAll" but Jasmine doesn't recognize these methods. A point in the right direction would be awesome!
describe('我稍后會在這里放一些更有意義的東西:)', function () {
describe('i will put something more meaningful here later :)', function () {
//not sure if this method actually exist in Jasmine
afterAll(function () {
//restart browser or something of the nature
});
it('should do stuff', function () {
});
it('do stuff', function () {
});
});
瀏覽器應該關閉,然后重新打開以運行下一個規范.
browser should then close, and then open back up to run the next spec.
推薦答案
說到測試之間重啟瀏覽器,有一個相關的配置選項:
Speaking about restarting browser between tests, there is a relevant configuration option:
// If true, protractor will restart the browser between each test.
// CAUTION: This will cause your tests to slow down drastically.
restartBrowserBetweenTests: false,
將其設置為 true
.
僅供參考,這是初始功能請求:
FYI, Here is the initial feature request:
- 功能請求:可以選擇在每個測試用例/場景之間重新啟動新的瀏覽器會話一個>
beforeAll
和 afterAll
內置在 jasmine-2.x
中.要使它們工作,您需要將 jasmine2
設置為測試框架 在 量角器配置中:
beforeAll
and afterAll
are built into jasmine-2.x
. To make them work, you need to set jasmine2
as a testing framework in the protractor config:
exports.config = {
...
framework: 'jasmine2',
...
}
<小時>
對于jasmine-1.x
,有第三方jasmine-beforeAll
提供相同功能的包.
For jasmine-1.x
, there is a third-party jasmine-beforeAll
package that provides the same exact functionality.
這篇關于可以說,如何在每次量角器 -spec 測試后重新啟動或關閉瀏覽器的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!