Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I want to do something after each describe(not after each testcase) and before each describe, is there any way to do this? I have tried below format, but it gives me error that, before and after not defined, is it possible to do sometask before and after of each describe:

describe('testcase', function () {
    before(function () {
        --------------
    })
    beforeEach(function () {
       -----------------
    })
    afterEach(function () {
        --------------
    })
    after(function () {
        -----------------
    })
    it('task1', function () {
             -----------

    })it('task2', function () {
                  ------------------
    })
})
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
789 views
Welcome To Ask or Share your Answers For Others

1 Answer

As far as I understand, you want beforeAll and afterAll which were introduced in 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.

For the older jasmine versions, the same can be done with the help of jasmine-beforeAll package.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...