SpiraTest Integration with Jest Testing Framework Now Available

21-Feb-2019 by Inflectra Product News

We are pleased to announce the release of the SpiraTest Jest plugin. This new extension lets you integrate SpiraTest seamlessly into your web browser and/or NodeJS testing environment. With our new extension you can tell Jest to report back the results of your automated tests directly to SpiraTest in addition to logging to the console of the machine running the test.

About Jest

Jest is a JavaScript testing framework designed to ensure correctness of any JavaScript codebase. It allows you to write tests with an approachable, familiar and feature-rich API that gives you results quickly. Jest is a delightful JavaScript Testing Framework with a focus on simplicity. It works with projects using: Babel, TypeScript, Node, React, Angular, Vue and more!

About SpiraTest

How do you know that all of your requirements have been tested? Are you currently reliant on spreadsheets and documents? Do you have to juggle between separate tools such as Jira, Jenkins, and Selenium to keep track of it all? Do you wish your requirements management, testing tools, and defect trackers were all in sync?

SpiraTest is the powerful test management tool from Inflectra. SpiraTest is trusted by over 3,000 organizations to manage their testing activities.

What Does the Integration do Exactly?

The new Jest reporter will integrate Jest with SpiraTeam. It will create a new test run in SpiraTeam for each test executed in Jest.

How Do I Get The New Extension?

Simply go to the Spira Reporter for Jest NPM Page and install the package.

Setting up the integration

Install the integration by running npm i jest-spiratest in the root directory of your tests. Inside your package.json file, add the jest field with the format as shown below. You can see a full sample package.json at the bottom of this README.

"reporters": [
            "default",
            [
                "jest-spiratest",
                {
                    "url": "https://doctor/SpiraPlan",
                    "username": "fredbloggs",
                    "token": "{XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}",
                    "projectId": 1,
                    "releaseId": 1,
                    "testSetId": 1,
                    "testCases": {
                        "default": 20,
                        "storesCorrectly": 21,
                        "javascriptWorks": 16
                    }
                }
            ]
        ]

Fields are required unless otherwise noted.

Field Description
url The root URL of your SpiraTest instance without a '/' at the end
username The username you use to sign into SpiraTest
token Your RSS Token. Foundin your profile page as the RSS Token field. You must have RSS Feeds enabled for this to work
projectId The ID of the project you would like the Test Runs to be filed under
releaseId OPTIONAL - Use if you would like to associate created test runs with a release
testSetId OPTIONAL - Use if you would like to associated created test runs with a test set
testCases Must contain the default field within it and, optionally, specific test cases for a given test spec name
default Inside the testCases field, this is the ID of the default test case mapped to a created test run
<test_name> OPTIONAL - Use as many times as you would like to map a the created test run to a particular test case in SpiraTest. Note that capitalization, special characters and spaces are ignored both in testCases and the test declaration

Once you have added the SpiraReporter to jest as described above, you are all set!

Using the SpiraTest Reporter

Actually, you don't do anything different! Just run npm test or however you ran jest before and you should see test runs created in the project you specified!

Sample package.json with SpiraTest Integration

{
    "name": "sample",
    "scripts": {
        "test": "jest"
    },
    "jest": {
        "reporters": [
            "default",
            [
                "jest-spiratest",
                {
                    "url": "https://doctor/SpiraPlan",
                    "username": "fredbloggs",
                    "token": "{XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}",
                    "projectId": 1,
                    "releaseId": 1,
                    "testSetId": 1,
                    "testCases": {
                        "default": 20,
                        "storesCorrectly": 21,
                        "javascriptWorks": 16
                    }
                }
            ]
        ]
    }
}