Skip to main content
Example Project

See a working example: bistro-e2e-cypress — Cypress E2E tests with QA Sphere integration.

Cypress Integration

This guide covers Cypress-specific setup. For install/auth/upload-command reference, see Overview, Auth, and Result Upload.

Prerequisites

  • QAS CLI installed and authenticated — see the Overview. Node.js 20+ recommended for Cypress.
  • Cypress test project.

Configure the JUnit reporter

Cypress does not produce JUnit XML out of the box. The recommended setup uses cypress-multi-reporters with mocha-junit-reporter to print spec output and write JUnit XML in parallel.

npm install --save-dev cypress-multi-reporters mocha-junit-reporter

Create reporter-config.json:

{
"reporterEnabled": "spec, mocha-junit-reporter",
"mochaJunitReporterReporterOptions": {
"mochaFile": "cypress/reports/junit/results-[hash].xml"
}
}

Reference it from cypress.config.ts:

// cypress.config.ts
import { defineConfig } from 'cypress';

export default defineConfig({
e2e: {
baseUrl: 'https://your-app-url.com',
specPattern: 'cypress/e2e/**/*.cy.ts',

screenshotOnRunFailure: true,
video: true,
videosFolder: 'cypress/videos',
screenshotsFolder: 'cypress/screenshots',

reporter: 'cypress-multi-reporters',
reporterOptions: {
configFile: 'reporter-config.json',
},
},
});

The [hash] placeholder in mochaFile produces one JUnit XML file per spec (e.g. results-abc123.xml), so uploads need a shell glob.

Mark tests with QA Sphere markers

Cypress uses Mocha-style test names, which support the hyphenated PROJECT-SEQUENCE marker format. Place the marker at the start of the test name:

// cypress/e2e/cart.cy.ts
describe('Cart', () => {
it('BD-023: User should see product list on the Checkout page', () => {
cy.visit('/');
cy.get('.menu-item').first().find('.add-to-cart').click();
cy.get('.checkout-btn').click();
cy.get('.checkout-items').should('be.visible');
});

it('BD-022: User should place order with valid data', () => {
// ...
});
});

For all supported marker formats and matching rules, see Result Upload — Test case matching.

Upload results

Pass every per-spec JUnit XML via shell glob:

npx qas-cli junit-upload --attachments cypress/reports/junit/results-*.xml

A convenient npm script:

{
"scripts": {
"test": "cypress run --browser chrome",
"test:upload": "npm test && npx qas-cli junit-upload --attachments cypress/reports/junit/results-*.xml"
}
}

For the full option reference, run-name templates, and modes (new run vs existing), see Result Upload.