You can find more information on the mechanisms and constraints regarding imports of test execution results here for Xray server and here for Xray cloud.
The first one tries to find an <h1> element with text Example Domain.
The second one asserts that the page contains an <a> element with a href attribute.
The third one tries to find an <img> element, which does not exist on the page.
When uploading the results, the plugin will create a test execution issue containing the three executed test issues.
Since Cypress automatically takes screenshots on failure, the execution will also contain the screenshot as evidence for the failed test case.
describe("the upload demo",()=>{beforeEach(()=>{cy.visit("https://example.org");});it("CYP-410 Contains a title",()=>{cy.get("h1").should("contain.text","Example Domain");});it("CYP-411 Contains a link",()=>{cy.get("a").should("have.attr","href");});it("CYP-412 Fails a test",()=>{cy.get("img").should("be.visible");});})
The following example consists of three scenarios for https://example.org, wrapping the tests described above.
Since we know that the image test will always fail, we'll mark it as skipped to make use of custom Xray statuses (see here for more information).
Note
The Cucumber preprocessor plugin reports skipped scenarios by marking all the steps they contain as skipped.
To mark a Cucumber test as skipped in Xray, you need to specify the respective step status.
Xray will then combine the steps' statuses according to your status settings into an overall test status (e.g. if at least one step was skipped, the entire test will be considered skipped).
When uploading the results, the plugin will create a test execution issue containing the three executed scenarios.
As the third scenario has been marked as skipped and a custom status has been provided for skipped steps, the entire test for the image verification will also be marked as skipped.
Note
Please read the Cucumber setup guide if you're confused about what's going on below.
Feature: Example page UI tests # Each scenario must be tagged with its corresponding # Jira test issue key and global Xray tag prefix. @TestName:CYP-410Scenario: A title is visible Given the example pageThen the title is visible@TestName:CYP-411Scenario: A link is visible Given the example pageThen the link is visible@skip@TestName:CYP-412Scenario: An image is visible Given the example pageThen an image is visible
import{Given,Then}from"@badeball/cypress-cucumber-preprocessor";Given("the example page",()=>{cy.visit("https://example.org");});Then("the title is visible",()=>{cy.get("h1").should("contain.text","Example Domain");});Then("the link is visible",()=>{cy.get("a").should("have.attr","href");});Then("an image is visible",()=>{cy.get("img").should("be.visible");});