Halo CLI with Cypress
Run your Cypress tests and generate the results XML files
Cypress will generate one or multiple XML files for a full suite of tests. These XML files can be uploaded to Halo.
To generate the XML file(s), set your Cypress config reporter to junit
as follows:
const { defineConfig } = require("cypress");
module.exports = defineConfig({
reporter: 'junit',
reporterOptions: {
mochaFile: 'results/test-results-[hash].xml',
jenkinsMode: true,
outputs: true,
testCaseSwitchClassnameAndName: true
}
});
cypress run
This will generate one or multiple XML files in the results
directory.
Uploading your Cypress test results to Halo
To upload the XML results file(s) to Halo, install the Halo CLI.
Generate an API key in Halo from the project 'Settings' page. API keys are project specific and will dictate the project to which data is sent.
You can also include metadata in your Halo reporting with the use of the '--metadata' flag. Any following environment variables with the HALO_
prefix will be uploaded as metadata.
For security reasons, HALO_TOKEN will not be stored or displayed.
- Example
- Windows
export HALO_TOKEN=<apiKey>
halo cypress \
--files results/*.xml \
--instance https://<orgId>.testevolve.io \
--label cypress-regression \
--metadata KEY=VALUE --metadata KEY=VALUE \
set HALO_TOKEN=<apiKey>
halo cypress \
--files results/*.xml `
--instance https://<orgId>.testevolve.io `
--label cypress-regression `
--metadata KEY=VALUE --metadata KEY=VALUE `
set HALO_TOKEN=<apiKey>
halo cypress \
--files results/*.xml ^
--instance https://<orgId>.testevolve.io ^
--label cypress-regression ^
--metadata KEY=VALUE --metadata KEY=VALUE ^
You should now see your labelled Cypress test results in Halo. If you used a new label or a label that is not currently assigned to a Halo hierarchy node, you'll find the results on the 'Unassigned Labels' page as well as the 'Home' page.
If you used a label that is assigned to a Halo hierarchy node, you'll find the results on the targeted node as well as the 'Home' page.