How can I have a beforeAll function in Jasmine ? (Not coffeeScript)

前端 未结 4 2019
半阙折子戏
半阙折子戏 2021-02-05 03:54

I need to know if there is a way to include or use a beforeAll function, or something similar, so I can login to my application and then start testing.

Right now I\'m pu

4条回答
  •  面向向阳花
    2021-02-05 04:22

    You can nest as many describe functions as you want. So you can do something like...

    describe("General Test", function () {
    
        function login(){
            //This code will run once at he beginning of your script
        };
    
        login();
    
        beforeEach(function () {
            //anything in here will apply to everything in each nested describe
        });
    
        describe("Specific Test", function () {
            //Applied here
        });
    
        describe("Another Specific Test", function () {
            //And here
        });
    
    
    });
    

提交回复
热议问题