npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

cypress-zapi-js

v1.0.9

Published

Lib for connection between Cypress and Zephyr, enabling execution update via API

Downloads

710

Readme

cypress-zapi-js

Lib for connection between Cypress and Zephyr, enabling execution update via API.

Pre-requisites:

To work properly will be necessary to create/update some files: the files cypress.json, cypress.env.json and cypress/plugins/index.js

  • Update the file cypress/plugins/index.js adding:
  const path = require("path");
  
  on("task", {
    getPackagePath() {
      return path.dirname(require.resolve("cypress-zapi-js/package.json"));
    },
  });
  • Add the environment variables bellow on your cypress.json or cypress.env.json:
  "cypress-zapi": {
  "updateJira": true, <!-- // false = after test execution will not update the Jira | true = after test execution will update the Jira -->
  "uploadAttachOnFailure":true, // false = If test fail will not upload evidence (cypress screenshot) | true = If test fail will upload evidence (cypress screenshot)
  "baseUrl": "https://prod-api.zephyr4jiracloud.com/connect", // Zephyr Api base url
  "accessKey": "NzY0NWQyNWMtxxxxxxxxxxxxxxxxxxxxxxxxxxxmMzQyNTYyMzIzNjA3MDAzODU0MGYyMyBjeXByZXNzMQ", // User access key. See: https://cucumberforjira.atlassian.net/wiki/spaces/C4JD/pages/13139969/How+to+automatically+push+Cucumber+test+results+into+a+Zephyr+test+cycle
  "secretKey": "PaI_EcWna9-xxxxxxxxxxxxxxxx-Z_wz1aZS0Q", // User secret key. See: https://cucumberforjira.atlassian.net/wiki/spaces/C4JD/pages/13139969/How+to+automatically+push+Cucumber+test+results+into+a+Zephyr+test+cycle
  "accountId": "5f3xxxxxxxxxxxxxxxxxxxxxx", // Account Id. See: https://community.atlassian.com/t5/Jira-questions/how-to-find-accountid/qaq-p/1111436
  "projectId": "10000", // Jira project Id. See: https://confluence.atlassian.com/jirakb/how-to-get-project-id-from-the-jira-user-interface-827341414.html
  "versionId": "10007", // Jira project version. See: https://support.atlassian.com/jira-core-cloud/docs/view-and-manage-a-projects-versions/
  "assignee": "erickvalentin", // Jira username
  "cycles": {
    "copyTestsFromOtherCycle": true, // false = Copy tests from another cycle | true = Don't copy tests from another cycle
    "currentCycle": "Cycle6 - Sprint 3", // Cycle of the tests that will be executed
    "copyFromCycle": "Cycle - Sprint 3", // If 'copyTestsFromOtherCycle' = true, the tests of this cycle will be copied to the currentCycle
    "copyFromVersionId": "10001" // If 'copyTestsFromOtherCycle' = true, the tests of this version will be copied to the currentCycle
  }
}
  • On cypress/support create a hook file zephyr-base.js
const ZAPI = require("cypress-zapi-js");

before(() => {});

beforeEach(() => {});

afterEach(() => {
  Cypress.on("uncaught:exception", (err) => {
    throw err;
  });

  if (Cypress.env("cypress-zapi").updateJira) {
    cy.log("Update Jira Enabled");
    cy.task("getPackagePath").then((packagePath) => {
      const testResult = Cypress.mocha.getRunner().suite.ctx.currentTest.state;
      let intTestResult = "0";
      const titleString = Cypress.mocha.getRunner().suite.ctx.currentTest.title;
      const issueKey = titleString.substr(0, titleString.indexOf(",")).trim();
      switch (testResult) {
        case "passed":
          intTestResult = "1";
          break;
        case "failed":
          intTestResult = "2";
          break;
        default:
          intTestResult = "-1";
      }
      try {
        ZAPI.createExecution(
          Cypress.env("cypress-zapi").baseUrl,
          Cypress.env("cypress-zapi").accessKey,
          Cypress.env("cypress-zapi").secretKey,
          Cypress.env("cypress-zapi").accountId,
          Cypress.env("cypress-zapi").projectId,
          Cypress.env("cypress-zapi").versionId,
          issueKey,
          Cypress.env("cypress-zapi").cycles.currentCycle,
          intTestResult,
          Cypress.env("cypress-zapi").uploadAttachOnFailure,
          Cypress.env("cypress-zapi").cycles.copyTestsFromOtherCycle,
          Cypress.env("cypress-zapi").cycles.copyFromCycle,
          Cypress.env("cypress-zapi").cycles.copyFromVersionId,
          packagePath
        );
      } catch (error) {
        console.error(`Error to update the status on Jira: ${error}`);
      }
    });
  } else {
    cy.log("Update Jira Disabled");
  }
});

after(() => {});
  • Add this config to your cypress.json:
"trashAssetsBeforeRuns":true

Note: The config above will clean the cypress screenshot folder after run the scenarios.

  • Finnaly update your file cypress/support/index.js adding:
import './zephyr-base';

How to implement the tests:

  • With cucumber and cypress:
// Google.feature

Feature: Google Main Page

  I want to open a search engine
  
  Scenario: TES-39, Validates fields new // The issue code should be added to the test title (TES-39)
    Given I open Google page
 

Authors