npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

customised-xray-cypress-reporter

v1.1.0

Published

customised-xray-cypress-reporter is a custom reporter for use with [Mocha](https://mochajs.org/), [XRay](https://www.getxray.app/) (Native Test Management for Jira) and [Cypress](https://www.cypress.io/) testing frameworks. The reporter helps you to int

Downloads

432

Readme

customised-xray-cypress-reporter

customised-xray-cypress-reporter is a custom reporter for use with Mocha, XRay (Native Test Management for Jira) and Cypress testing frameworks.
The reporter helps you to integrate your Cypress/Mocha test with XRay easily by producing enriched JUnit-style XML test report files which can be uploaded into XRay with API or other tools.
The reporter is built on the top of mocha-junit-reporter v2.2.0 so all the configurations in the official doc, are inherited from this npm package.
This reporter offers the ability to specify a Jira-Issue for each it{} inside your cypress test and creates a custom report that is easy to load into XRay.

Installation

As a dev module:

$ npm install customised-xray-cypress-reporter --save-dev

or as a global module:

$ npm install -g customised-xray-cypress-reporter

Configuration

Test level

describe('My First Test', () => {
  it('Does not do much!', {xray:{jiraID:"CALC-1234"}}, () => {
    expect(true).to.equal(true);
  })
})

Cypress configuration file (cypress.config.js)

const { defineConfig } = require("cypress");
module.exports = defineConfig({
  reporter: "customised-xray-cypress-reporter",
  reporterOptions: {
    mochaFile: "cypress/results/my-test-output-[hash].xml"
  },
  e2e: {
    setupNodeEvents(on, config) {
      // implement node event listeners here
    },
  },
});

Every other {reporterOptions} explained here: mocha-junit-reporter v2.2.0 are availabile.

Example

  1. Install 'customised-xray-cypress-reporter' to the cypress project
$ npm install customised-xray-cypress-reporter --save-dev
  1. Configure 'customised-xray-cypress-reporter' as the reporter and do other configurations as necessary. Configurations can be done in the cypress.config.js or in the command line.
    Add this to cypress.config.js
const { defineConfig } = require("cypress");
module.exports = defineConfig({
  reporter: "customised-xray-cypress-reporter",
  reporterOptions: {
    mochaFile: "cypress/results/my-test-output-[hash].xml"
  },
  e2e: {
    setupNodeEvents(on, config) {
      // implement node event listeners here
    },
  },
});

'mochaFile' is the path to the report file. When there are several test files run it will generate a report file for each test file, so in order to generate unique file names and not overwrite the existing ones, the [hash] is added to the name of the report file.

  1. Add cypress test with XRay-related elements
describe('My First Test', () => {
        it('Does not do much!', {xray:{jiraID:"CALC-1234"}}, () => {
            expect(true).to.equal(true);
        })
    })
  1. Run tests and generate report
npx cypress run --spec "path/to/file"
  1. View report file

Report file generated at '<Cypress_project_root>/cypress/results'.

"my-test-output-828a1c4885dc687b1a19e11e24b9437e.xml"

<?xml version="1.0" encoding="UTF-8"?>
<testsuites name="Mocha Tests" time="0.1070" tests="1" failures="0">
  <testsuite name="Root Suite" timestamp="2023-01-27T13:51:23" tests="0" file="cypress\e2e\test.cy.js" time="0.0000" failures="0">
  </testsuite>
  <testsuite name="My First Test" timestamp="2023-01-27T13:51:23" tests="1" time="0.0700" failures="0">
    <testcase name="My First Test Does not do much!" time="0.0820" classname="Does not do much!">
      <properties>
        <property name="test_key" value="CALC-1234"/>
      </properties>
    </testcase>
  </testsuite>
</testsuites>

As you can see the property has beenn added and now could be readed correctly by XRay.

<properties>
  <property name="test_key" value="CALC-1234"/>
</properties>
  1. Now just upload the report to XRay and the card in Jira will be updated automatically

THE JOB IS DONE!

Happy testing to everyone!

a.