1

I am working as a QA and got a chance to integrate Xray with Jira and cypress for automation testing.

I have integrated cypress with xray by following this documentaion -> https://qytera-gmbh.github.io/projects/cypress-xray-plugin/ I have integrated the Xray with my Jira Board successfully. I am assuming that Cypress and Xray integration working because when I am executing cypress script at that time a new Test issue ticket and Test Execution ticket created successfully on jira board.

I have setup the configuration in cypress.config.js file. Here is the code :

const { defineConfig } = require("cypress");

const { addXrayResultUpload, configureXrayPlugin } = require("cypress-xray-plugin/plugin");

module.exports = defineConfig({
  waitForAnimations: false,
  animationDistanceThreshold: 50,
  videoCompression: false,
  trashAssetsBeforeRuns: false,
  e2e: {
    baseUrl: "http://localhost:3000/",
    env: {
      jiraApiToken: 'shgvgsyashdgvyhsgdaygshduyjscgbsdydhjcbjyhdchn',
      jiraApiBaseUrl: 'https://xyz.atlassian.net/rest/api/2',
      jiraUserName: 'xyz@email.com'
    },
    setupNodeEvents(on, config) {
      configureXrayPlugin({
        jira: {
          projectKey: "PZA",
          url: "https://xyz.atlassian.net",
          jiraTestIssueType: 'Test',
          createTestIssues: false,
          createTestExecutionIssues: false,
          testExecutionIssueDescription: "This test run was approved by Prachi.",
          testExecutionIssueSummary: "Finaly..............Test Success ",
          jiraTestExecutionIssueType: 'Test Execution',
          testExecutionIssueKey: "PZA-81",
         testIssueKey: "PZA-80",
          assignee: 'xyz@email.com'
        },
        xray: {
          createTestExecutionIssues: false,
          createTestIssues: false,
          uploadResults: true
        }
      });
      addXrayResultUpload(on) ;
      return config;
    }
  },
  component: {
    devServer: {
      framework: "create-react-app",
      bundler: "webpack"
    }
  }
});

I am using below properties for make it disable but execution property is not working

createTestExecutionIssues: false,
createTestIssues: false,

Here is my newTest.cy.js file

import React from "react";

<reference types="cypress" />

import "cypress-xray-plugin/register";

import {
  JOINTHEADERMENU, imgJson
} from "./constant";

describe(" New Test", () => {
  
  //Here we have specified the Test issue id in inside it block 
  it("PZA-80", async () => {
    cy.viewport(1440, 900);
    cy.visit(`${Cypress.config().baseUrl}login`);
    cy.get('img[src="/images/logo.svg"]').should("be.visible");

    cy.wrap(JOINTHEADERMENU).each((str) => {
      cy.log(str);
      cy.contains(str).should("be.visible");
    });

    cy.contains("PERSONAL").should("be.visible").click().wait(5000);
    cy.url().should("eq", `${Cypress.config().baseUrl}personal`);

    cy.get('img[src="/images/personalLanding.svg"]').should("be.visible");


    cy.get('img[src="/images/personalLanding.svg"]').should("be.visible");

    cy.contains("FOR MYSELF").should("be.visible");

    cy.contains("Don’t miss out on the wellbeing benefits because you work for yourself").should(
      "be.visible"
    );
    cy.contains(
      "pirkx brings together benefits to help you affordably improve your financial wellbeing, health and much more."
    ).should("be.visible");
    cy.contains("ONLINE DEMO").should("be.visible");

    cy.contains("WHY PIRKX?").should("be.visible").click().wait(5000);
    const newImgJson = imgJson.map((obj) => {
      cy.contains(obj.text).should("be.visible");
      cy.get(`img[src="${obj.image}"][alt="First"]`).should("be.visible");
    });
   
  });

  
}); 

I want to do this jira and xray configuration dynamic for each test script so that I can change test execution and test issue key Id's.

Or

If it is not possible so I want to make it disable so that when I am running any script then new jira tickets for Test Execution and Test Issue will not create and existing ticket will update based on assigned ticket id to the particular test script.

1 Answers1

0

To run the test with the same execution key you will have to include the JIRA_TEST_EXECUTION_ISSUE_KEY environment variable along with the run script.

npx cypress run --env JIRA_TEST_EXECUTION_ISSUE_KEY="PRJ-123"

So for every new test execution, you will have a separate run script with a unique JIRA_TEST_EXECUTION_ISSUE_KEY.

To keep the issue key same, make sure that the "it" block has the same name

it("PZA-80", async () => {});

Source:

https://qytera-gmbh.github.io/projects/cypress-xray-plugin/section/configuration/jira

https://qytera-gmbh.github.io/projects/cypress-xray-plugin/section/guides/uploadTestResults/

https://qytera-gmbh.github.io/projects/cypress-xray-plugin/section/guides/targetingExistingIssues/

Wasim
  • 896
  • 7
  • 24