Zakir Sayed
Zakir Sayed

Reputation: 200

Add test dependency in Protractor & Jasmine test framework

I looked up controlling the test flow but couldn't find a direct way to do it. Still wondering if someone found an alternate way to manage below situation.

How to write test case which are dependent on previous test case success? Consider below example:

describe('Test scenario started', function() {
    BeforeEach(function() {
        //Doing the login here and executing it once
    });

    it('TC001 (independent)', function() {
        // Perform steps and validate
        // Click a link for newpage and verify it's loaded
    });


    describe('Navigate to next page', function() {
        it('TC002 (Dependent on success of TC001)', function() {
            // Perform steps and validate
            // Click a link for nav to page #3 and verify it's loaded
        });

        describe('Navigate to Page #3', function() {
            it('TC003 (Dependent on success of TC002)', function() {
                // Page #3 is available, let's perform the tasks now
            });
        })
    });
});

I'd like to skip the test which are dependent if the parent test case fails thereby avoiding unnecessary delay of trying to execute them. I can add all the functionality to one test case but breaking up in smaller cases is something we prefer.

Anyone have an elegant way to handle this?

Upvotes: 0

Views: 985

Answers (1)

Priyanshu
Priyanshu

Reputation: 3058

You can use any one of the below:

jasmine-bail-fast

jasmine-fail-fast

It will allow you to fail tests faster.

Upvotes: 1

Related Questions