Global Set Up in Cypress

Viewed 214

before() & after() hooks in Cypress run before and after every spec. Is there means by which I can perform certain operations only once at the start of the run and then at the end.

In my Cypress framework, I'm trying to update the results of the Tests in TestRail post execution.

I have 4 specs in a module - Spec1, Spec2, Spec3, Spec4

In the Cypress support folder - before() I have a method that creates the TestRun in TestRail.

./cypress/support/testrail.js

before(function(){

    //Create Test Run In TestRail

}

In the after() hook of each of the specs, I update the TestRail TestRun.

./cypress/integration/modules/module1/spec1.js

describe("Suite 1", () => {

    beforeEach(function () {

    });

    it("Test 1", function () {

    });

    it("Test 2", function () {

    });

    after(function () {

        //Update Test Case Results In TestRail

  });

});

The challenge I'm facing is - Using npx cypress open, when I just run 1 spec from the Test Runner - a new TestRun is created and the status of the tests from the spec are correctly updated in the TestRail. But using npx cypress run, when I run the entire module, there are 4 different TestRuns created and the results of 4 specs are updated in 4 different TestRuns.

Is there a way by which I can update the results of all the specs in a single Test Run when run using npx cypress run?

0 Answers
Related