我正在为网络应用实现 Protractor 测试。我做了一些谷歌搜索,但我想出了 zip,我希望我创建的每个规范在浏览器运行该特定规范文件中的所有测试后关闭浏览器,然后继续下一个 -spec 文件,等等 我有诸如使用“beforeAll”和“afterAll”之类的东西,但 Jasmine 无法识别这些方法。指向正确方向的点会很棒!
describe('稍后我会在这里放一些更有意义的东西:)', 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 () {
});
});
然后浏览器应该关闭,然后重新打开以运行下一个规范。
最佳答案
关于在测试之间重启浏览器,有一个相关的配置选项:
// If true, protractor will restart the browser between each test.
// CAUTION: This will cause your tests to slow down drastically.
restartBrowserBetweenTests: false,
将其设置为 true
。
仅供引用,这是初始功能请求:
beforeAll
和 afterAll
内置于 jasmine-2.x
中。要使它们工作,您需要设置 jasmine2
as a testing framework在protractor config :
exports.config = {
...
framework: 'jasmine2',
...
}
对于jasmine-1.x
,有第三方jasmine-beforeAll
提供完全相同功能的包。
关于javascript - 如何,可以说,在每次 Protractor 规范测试后重新启动或关闭浏览器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28991395/