1.0.1 • Published 2 months ago

@qualitywatcher/cypress-reporter v1.0.1

Weekly downloads
-
License
ISC
Repository
github
Last release
2 months ago

QualityWatcher Reporter for Cypress

Publishes Cypress runs on QualityWatcher.

Install

$ npm install @qualitywatcher/cypress-reporter --save-dev

or

yarn add -D @qualitywatcher/cypress-reporter

Usage

  1. Add QualityWatcher module to cypress.config.{ts|js} or cypress/plugins/index.{ts|js}:

Define Config Setup

const { defineConfig } = require("cypress");
const qualitywatcher = require("@qualitywatcher/cypress-reporter");

module.exports = defineConfig({
  // ...
  e2e: {
    setupNodeEvents(on, config) {
      // implement node event listeners here
      // Call the report method with on and config as arguments
      qualitywatcher.report(on, config);
    },
  },
});

Plugin Setup

import * as qualitywatcher from "@qualitywatcher/cypress-reporter";

module.exports = (on, config) => {
  // Call the report method with on and config as arguments
  qualitywatcher.report(on, config);
};

or

const qualitywatcher = require("@qualitywatcher/cypress-reporter");

module.exports = (on, config) => {
  // Call the report method with on and config as arguments
  qualitywatcher.report(on, config);
};
  1. Add minimum reporterOptions to your cypress.config.{ts|js} or cypress.json:

testRunName: string test run title

description: string test run description

projectId: number project ID with which the tests are related

includeAllCases boolean (optional:true) whether or not to include all test cases from each suite used

report boolean (optional) whether or not to send results to QualityWatcher

cypress.config.{ts|js}

NOTE: You will be adding options to a qualitywatcher key in reporterOptions

const { defineConfig } = require("cypress");
const qualitywatcher = require("@qualitywatcher/cypress-reporter");

module.exports = defineConfig({
  reporterOptions: {
    qualitywatcher: {
      testRunName: "Test Run Name",
      description: "Test Run Description",
      projectId: 1,
      includeAllCases: true,
      //... use more optional options
      report: true,
      includeCaseWithoutId: true,
      complete: false,
      ignoreSkipped: true,
      generateShareableLink: true,
      parentSuiteTitle: "Smoke suite",
      screenshotFolder: "cypress/screenshots",
      uploadScreenshot: true,
      parallel: false,
    },
  },
  e2e: {
    //...
  },
});

or

cypress.json

{
  "reporterOptions": {
    "qualitywatcher": {
        "testRunName": "Test Run Name",
        "description": "Test Run Description",
        "projectId": 1,
        "includeAllCases": true,
        "report": true,
        "includeCaseWithoutId": true,
        "complete": false,
        "ignoreSkipped": true,
        "generateShareableLink": true,
        "parentSuiteTitle": "Smoke suite",
        "screenshotFolder": "cypress/screenshots",
        "uploadScreenshot": true,
        "parallel": false,
    }
  }
}

Full reporter options

OptionRequiredDescription
projectIdYesThe ID of the project.
testRunNameYesThe name of the test run.
descriptionYesA description of the test run.
includeAllCasesYesWhether to include all test cases from any suite that at least one automated result belongs to in the created run.
completeNoIf true, marks the test run as complete.
includeCaseWithoutIdNoInclude test cases even if they don't have Suite and Case IDs mapping, this will create new test case/s in QualityWatcher from results.
reportNoIf true, send results to QualityWatcher.
ignoreSkippedNoIf true, skipped tests will be ignored.
generateShareableLinkNoIf true, generates a shareable link for the report.
parentSuiteTitleNoThe suite where test cases without IDs will be added.
screenshotFolderNoThe folder where screenshots are stored.
uploadScreenshotNoIf true, uploads screenshots with the report.
parallelNoIf true, save results locally to be merged later when doing parallel testing.
  1. Get API Key from QualityWatcher

    1. Go to your QualityWatcher account
    2. Hover over your profile avatar and click "Profile Settings"
    3. Select the "API Key" menu item
    4. Click the "Generate API Key" button
    5. Copy your API Key, we will use this for posting the results
  2. Create a .env file in the root of your project and add API KEY, or update an existing .env

touch .env
echo "QUALITYWATCHER_API_KEY=[API Key]" >> .env

# For windows:
# type NUL > .env
# echo QUALITYWATCHER_API_KEY=[API Key]  > .env
  1. Install dotenv and require it in your plugin file (if you don't have this already)

cypress/plugins/index.{ts|js}

/// <reference types="cypress" />
// ***********************************************************
// This example plugins/index.js can be used to load plugins
//
// You can change the location of this file or turn off loading
// the plugins file with the 'pluginsFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/plugins-guide
// ***********************************************************

// This function is called when a project is opened or re-opened (e.g. due to
// the project's config changing)

require("dotenv").config();
import * as qualitywatcher from "@qualitywatcher/cypress-reporter";

/**
 * @type {Cypress.PluginConfig}
 */
// eslint-disable-next-line no-unused-vars
module.exports = (on, config) => {
  qualitywatcher.report(on, config);
};

If you don't have any tests in QualityWatcher you can still push your results and create new tests by enabling includeCaseWithoutId in your reporterOptions.

OR

If you have existing test cases ensure that your Cypress tests includes the ID of your QualityWatcher test case and suite that it belongs to. Make sure the suite and test case IDs are distinct from your test titles:

// Good:
it("[S12C1234] Can authenticate a valid user", ...
it("Can authenticate a valid user [S12C1234]", ...

// Bad:
it("S12C123Can authenticate a valid user", ...
it("Can authenticate a valid userS5C123", ...

Parallelization

When doing parallel testing, you need to merge results from different Cypress runs to get a complete report in QualityWatcher.

  1. Enable parallel in your qualitywatcher reporter options
reporterOptions: {
  qualitywatcher: {
    //...
      parallel: true
    //...
  }
}
  1. Execute merge binary when all parallel jobs are done:
npx @qualitywatcher/cypress-reporter-merge

License

This project is licensed under the MIT license.

1.0.2-beta.2

2 months ago

1.0.2-beta.0

2 months ago

1.0.2-beta.1

2 months ago

1.0.1

4 months ago

1.0.0

4 months ago

0.0.9

6 months ago

0.0.8

6 months ago

0.0.7

6 months ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago