{"id":20065766,"url":"https://github.com/inflectra/spire-testing-cypress","last_synced_at":"2025-10-17T09:58:46.452Z","repository":{"id":58479013,"uuid":"531341047","full_name":"Inflectra/spire-testing-cypress","owner":"Inflectra","description":"Sample Cypress project that uploads results to SpiraTest","archived":false,"fork":false,"pushed_at":"2024-06-22T04:36:56.000Z","size":1711,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-01T18:42:48.092Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Inflectra.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-09-01T02:56:37.000Z","updated_at":"2022-11-04T12:48:11.000Z","dependencies_parsed_at":"2023-01-18T16:15:32.473Z","dependency_job_id":null,"html_url":"https://github.com/Inflectra/spire-testing-cypress","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Inflectra%2Fspire-testing-cypress","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Inflectra%2Fspire-testing-cypress/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Inflectra%2Fspire-testing-cypress/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Inflectra%2Fspire-testing-cypress/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Inflectra","download_url":"https://codeload.github.com/Inflectra/spire-testing-cypress/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241494142,"owners_count":19971870,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-13T13:52:39.229Z","updated_at":"2025-10-17T09:58:41.405Z","avatar_url":"https://github.com/Inflectra.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Cypress Reporter for Spira\nThis is a sample cypress project that uploads Cypress test results automatically to Inflectra's SpiraTest, SpiraTeam or SpiraPlan (hereafter just Spira).\n\nIt is implemented as a custom reporter that you can easily add to your existing Cypress projects and have the benefit of the test results and screenshots automatically upload against the corresponding Spira test case.\n\n## Installing the Cypress Reporter\nTo install the Spira custom reporter, simply download the [Spira-Cypress-Reporter.zip](https://github.com/Inflectra/cypress-sample/raw/main/Spira-Cypress-Reporter.zip) zip file and extract the contents (consisting of the `reporter` folder) and place in your Cypress project at the same level as the `cypress` folder. For example:\n\n![Sample file view of a Cypress project](images/spira-reporter-1.png)\n\nTo use the custom Spira reporter in your Cypress project, you just add it to the Cypress command line:\n\n    npx cypress run --browser edge --spec \"cypress\\e2e\\1-getting-started\\todo.cy.js\" --reporter \"reporter\\SpiraReporter\"\n\nor you modify the `cypress.config.js` to include the report. We recommend this method since it avoids need to add it to the command-line each time.\n\nHowever before you can use the reporter, you will need to configure it to point to Spira, and map the Cypress spec files to specified Spira test cases.\n\n## Configuring the Cypress Reporter\nLocate the `cypress.config.js` file from the root of your Cypress project. Open this up in your favorite text/code editor, for example Visual Studio Code. This file contain something similar to the following:\n\n    const { defineConfig } = require(\"cypress\");\n\n    module.exports = defineConfig({\n        e2e: {\n            setupNodeEvents(on, config) {\n            on('task', { \n                log(message) {\n                console.log(message)\n                return null\n                },\n            })\n            },\n        }\n    });\n\nDepending on how you have Cypress configured, you may have additional settings.\n\nNow we need to modify it to enable the Spira custom reporter and configure its settings:\n\n    const { defineConfig } = require(\"cypress\");\n\n    module.exports = defineConfig({\n        e2e: {\n            setupNodeEvents(on, config) {\n            on('task', { \n                log(message) {\n                console.log(message)\n                return null\n                },\n            })\n            },\n        },\n        reporter: 'reporter/SpiraReporter',\n        reporterOptions: {\n            projectId: 1,\n            releaseId: 1,\n            testSetId: null,\n            login: 'fredbloggs',\n            apiKey: '{7A05FD06-83C3-4436-B37F-51BCF0060483}',\n            protocol: 'https',\n            host: 'demo-us.spiraservice.net',\n            vdir: 'mysite',\n            mapping: {\n            \"with a checked task\": 4,\n            \"with a checked task 2\": 5\n            }\n        }\n    });\n\nNotice that we have added `reporterOptions` object that specifies how the Cypress reporter will communicate with Spira:\n\n- **projectId** - this should be the ID of the Spira project (e.g. `PR:5` would be just `5`)\n- **releaseId** - this should be the ID of the Spira release we're reporting against (e.g. `RL:2` would be just `2`)\n- **testSetId** - this should be the ID of the Spira test set we're reporting against (e.g. `TX:3` would be just `3`)\n- **login** - this is the username for a valid Spira user\n- **apiKey** - this is the API Key / RSS Token associated with the Spira user\n- **protocol** - this should be either `http` or `https`\n- **host** - this should be the domain name of your Spira instance (e.g. demo-us.spiraservice.net or myinstance.spiraservice.net)\n- **vdir** - this should be the name of any virtual directory in your instance (e.g. `mysite`) or just empty if you have a URL that is just the domain (e.g. https://mysite.spiraservice.net)\n- **mapping**  - this is where we map our spec files to the test cases, we will explain this next.\n\n### Mapping the Test Cases\n\nThe `mapping` section is where we map the name of each test suite in a spec file with a corresponding Spira test case. For example, if we have a spec file that has this `context` section:\n\n    context('with a checked task', () =\u003e {\n        beforeEach(() =\u003e {\n        cy.contains('Pay electric bill')\n            .parent()\n            .find('input[type=checkbox]')\n            .check()\n        })\n\nThen the name of the test suite wiuld be `with a checked task` and then we map that to a test case in SpiraTest, for example `TC:5`. For our sample tests, we have the following example mapping:\n\n    mapping: {\n        \"with a checked task\": 4,\n        \"with a checked task 2\": 5\n    }\n\nSo we are mapping:\n- `with a checked task` to Spira test case `TC:4`\n- `with a checked task 2` to Spira test case `TC:5`\n\nWe have now finished our configuration of the reporter, and can run the tests.\n\n## Running a Cypress Test\nYou can execute the tests using the Cypress command-line, launch-pad, CI tool or whatever method you currently use. For example, to execute one of the sample tests in this repository, you can use:\n\n    npx cypress run --browser edge --spec \"cypress\\e2e\\1-getting-started\\todo.cy.js\"\n\nto run the entire folder of tests, you can use:\n\n    npx cypress run --browser edge --spec \"cypress\\e2e\\1-getting-started\"\n\nThe system will then execute the test and let you know that it is reporting back to Spira:\n\n![Console output when running the test using the Spira reporter](images/spira-reporter-2.png)\n\n### Viewing the Results in Spira\n\nOnce the Cypress tests have finished running, you can view the results in Spira:\n\n![List of Cypress test runs in Spira](images/spira-reporter-3.png)\n\nIf you click on one of the runs, you will see the details of that specific execution, including the pass/fail steps and the actions recorded:\n\n![Details of a Cypress test run in Spira](images/spira-reporter-4.png)\n\nIn addition, if you choose one of the failed runs, you will see that any screenshots have been automatically uploaded as well:\n\n![List of screenshots attached to the test run in Spira](images/spira-reporter-5.png)\n\nIf you click on the picture link, you can view the uploaded image/screenshot directly in Spira:\n\n![Viewing a test run screenshot in Spira](images/spira-reporter-6.png)\n\n**Congratulations! You have now run your first Cypress test and reported back the results to Spira!**\n\n## Where Can I Obtain Spira?\n\nIf you would like to learn more about the Inflectra Spira suite, please go to the following website:\n- [SpiraTest](https://www.inflectra.com/SpiraTest/), powerful requirements and test management\n- [SpiraTeam](https://www.inflectra.com/SpiraTeam/), agile planning and test management for teams\n- [SpiraPlan](https://www.inflectra.com/SpiraPlan/), enterprise planning and testing platform","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finflectra%2Fspire-testing-cypress","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finflectra%2Fspire-testing-cypress","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finflectra%2Fspire-testing-cypress/lists"}