我想在每个描述之后(而不是每个测试用例之后)和每个描述之前做一些事情,有什么办法可以做到这一点?我尝试过以下格式,但它给了我一个错误,即未定义之前和之后,是否可以在每个描述之前和之后执行某些任务:
describe('testcase', function () {
before(function () {
--------------
})
beforeEach(function () {
-----------------
})
afterEach(function () {
--------------
})
after(function () {
-----------------
})
it('task1', function () {
-----------
})it('task2', function () {
------------------
})
})
最佳答案
据我了解,你想要 beforeAll
and afterAll
这是在 jasmine 2.1
中引入的:
The beforeAll function is called only once before all the specs in describe are run, and the afterAll function is called after all specs finish. These functions can be used to speed up test suites with expensive setup and teardown.
对于旧的 jasmine
版本,可以在 jasmine-beforeAll
package 的帮助下完成相同的操作。 .
关于angularjs - 使用带有 angularjs 的 selenium 服务器在 Protractor 中描述后做一些事情,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27415507/