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

xray-formatter

v2.1.5

Published

jira xray formatter for cucumber framework

Downloads

295

Readme

npm version

xray-formatter

This is an Xray formatter for Cucumber automation framework. Use this formatter if you use Xray Jira plugin for managing your automation test cases and running them via Xray Test Executions.

  1. Installation
  2. Usage
  3. CLI commands

Installation

To install the package, run:

npm install xray-formatter

Add the reporter configuration to your Cucumber config file.

Usage

For this reporter to work correctly, Cucumber tests need to have their unique Jira IDs saved in the tags. If the test has several Jira tags, only the first one will be used to save the result.

Feature: Feature

  @PC-12345
  Scenario: Some Test

Save results in a file

By default, only regexp and report options needs to be provided. The regular expression needs to match the Jira tags and return the ID as the first capturing group.

The results of the test run will be saved in a file, which can be manually imported in a Xray Test Execution ( see docs).

module.exports = {
  default: {
    format: [
      'xray-formatter:reports/xray.json',
    ],
    formatOptions: {
      jiraOptions: {
        regexp: /(PC-\d+)/,
        report: './reports/xray.json'
      }
    }
  }
}

Send results to Jira

If you want to send the results to Xray Test Execution automatically, you need to provide endpoint, token and execution options.

module.exports = {
  default: {
    format: [
      'xray-formatter:reports/xray.json',
    ],
    formatOptions: {
      jiraOptions: {
        endpoint: 'https://jira.company.com/jira/',
        token: '123456789',
        execution: 'PC-7',
        regexp: /(PC-\d+)/,
        report: './reports/xray.json',
      }
    }
  }
}

The results will be updated in real time.

Note

  • This formatter uses default Xray test statuses: 'TODO', 'PASS' and 'FAIL'.
  • In order to avoid reporting false positive results for Scenario Outlines, the formatter will not change any test's status from 'FAIL' to 'PASS'. If you need to rerun tests from an execution, set them in 'TODO' status manually or provide resetTests option in the config.

Options

| Name | Type | Example | Description | Optional | |------------|----------|------------------------------------|-----------------------------------------------------------------------------------------------------------------------|----------| | regexp | RegExp | /@jira\((\w+-\d+)\)/ | Regular expression for getting a test's Jira ID from its tags. The first capturing group should return the ID. | No | | report | string | ./report/xray.json | Path to the file where the xray report will be saved. | No | | endpoint | string | https://jira.company.com/jira/ | Your Jira endpoint. | Yes | | token | string | | Jira API token. See docs. | Yes | | execution | string | PC-7 | The ID of your Xray Test Execution. | Yes |
| resetTests | string[] | ['PC-1', 'PC-2', 'PC-3'] | An array of tests which should be reset in 'TODO' status before the run. | Yes | | pageLimit | number | 100 | Max number of items returned by Xray API. Default is 200, set to another number if you have custom settings. | Yes |

CLI commands

Before running CLI commands, create a configuration file with your Jira endpoint and an access token.

By default, the package will search for xray.config.json in your root directory. To set a custom path, pass it in your command as a --config argument.

Example of a basic xray.config.json file:

{
  "endpoint": "https://jira.company.com/jira/",
  "token": "12345"
}

xray-upload

xray-upload --execution PC-1 --path ./report/xray.json

This command uploads test results from a JSON Xray report to the Xray execution.

Options:

  1. execution - ID of your Test Execution.
  2. path - path to your xray report.

xray-clear

xray-clear --execution PC-1

This command sets all tests in the execution in TODO status.

Options:

  1. execution - ID of your Test Execution.

xray-extract

xray-extract --execution PC-1
xray-extract --report ./report/xray.json

This command extracts IDs of failed/unexecuted tests from a Text Execution or an xray report file, and saves them as a Cucumber tag string. The string can be used to re-run those tests.

By default, the tags are saved in a @id1 or @id2 or @id3 format. If you use a different format to mark your tests with their Jira IDs, you can provide a --format option.

xray-extract --execution PC-1 --format "@jira(id)"

Options:

  1. execution - ID of your Test Execution.
  2. report - path to your xray report.
  3. format - format for saving the tags.
  4. path - path to a file where the tag string will be saved. Default: ./tags.txt

xray-import

xray-import --path ./features/ --regexp "(PC-\d+)" --tests PC-1 PC-2 PC-3

This command parses .feature files and updates steps in Jira scenarios with a corresponding ID.

To use this command, you need to add customFields property to your xray config. This property should contain custom field IDs for test type, scenario type and steps; as well as value IDs for "Cucumber" test type and "Scenario"/"Scenario Outline" scenario types.

Custom fields in a Jira issue

These fields and values are unique for every Jira instance, and you can look them up in Xray configuration or by inspecting elements on the page.

{
  "endpoint": "https://jira.company.com/jira/",
  "token": "12345",
  "customFields": {
    "testTypeField": "customfield_10112",
    "cucumberTypeId": "10001",
    "scenarioTypeField": "customfield_10113",
    "scenarioTypeId": "10003",
    "scenarioOutlineTypeId": "10004",
    "stepsField": "customfield_10114"
  }
}

Options:

  1. path - path to your feature files.
  2. regexp - regular expression for getting a test's Jira ID from its tags..
  3. tests - (optional) IDs of tests that should be updated.