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 🙏

© 2026 – Pkg Stats / Ryan Hefner

cypress-zapi-util

v2.2.4

Published

Utility for updating test results in 'Zephyr for Jira'. It also enables to clone an existing cycle

Readme

cypress-zapi-util

This library help us to create a test cycle after cloning from an existing one. After creating cycle (or use an existing), library can update the test results in Jira-Zephyr

cypress.json

"env": {
	"dryRun": false, //true: if you are running test locally and DONT want to update results in Jira-Zephyr
	"jiraProjectId": "18881", //project id from Jira
	"cycleIdToBeClone": "3553", //cycle to be cloned 
	"cloneCycle": false, // true: if you want to clone new cycle, false: if you want to update results in an existing cycle
	"versionId": "", //Use numeric value i.e 28921 for released and -1 /blank for unreleased
	"errorFilePath": "D:\\Work\\Error.txt", //some file for storing error and exceptions
	"apiBaseURL": "https://jira.mycompany.com/rest/zapi/latest",
	"auth": "ZZyyxx" //basic auth token
	"rootFolderScreenShot": "D:\\Work\\Cypress\\Code\\cypress\\screenshots\\", //screenshots root folder
	"cycleIdFile": "D:\\Work\\Cypress\\Code\\cypress\\screenshots\\cycle.txt" //file where we store cycle id. 
}

In case you want to clone new cycle make sure you change cloneCycle to true and delete existing cycle text file which is configured cycleIdFile

Installation

npm i cypress-zapi-util

Usage

cypress\support

Create base.js

var ZAPI = require('cypress-zapi-util');
var path = require('path');

beforeEach(() => {

})

afterEach(() => {
	Cypress.on('uncaught:exception', (err, runnable) => {
		throw err
	})
	if(!Cypress.env('dryRun')) {
		const testResult = Cypress.mocha.getRunner().suite.ctx.currentTest.state;
		let intTestResult = "0";
		let titleString = Cypress.mocha.getRunner().suite.ctx.currentTest.title;
		let issueKey = "";
		//It('Issue: TMP-727, CycleId: 3581 ~ Should do something5', () => …)
		//If you provide CycleId: 3581 then CycleId from Configuration will be overwritten and will be used for updating result 
		cy.task('getZapiPackagePath').then((packagePath) => {	
			cy.exec('node "'+packagePath+path.sep+'custom'+path.sep+'helper" getValueByTypeFromString "'+ titleString+'" "Issue"').then((results) => {
				let result = results.stdout.replace('--------make-runnable-output--------','').replace('------------------------------------', '').trim();
				if(result.includes('undefined') || result.includes('Error')) {
					cy.writeFile(Cypress.env('errorFilePath'), result+"\n",{ flag: 'a+' });
				} 
				else {
					issueKey = result;
					console.log('Utility is updating results for '+issueKey);
					switch (testResult) {
					case 'passed':
						intTestResult = "1";
						break;
					case 'failed':
						intTestResult = "2";
						break;
					default:
						intTestResult = "-1";
					}	
					cy.exec('node "'+packagePath+path.sep+'custom'+path.sep+'helper" getValueByTypeFromString "'+ titleString+'" "CycleId"').then((results) => {
						result = results.stdout.replace('--------make-runnable-output--------','').replace('------------------------------------', '').trim();
						if(result.includes('undefined') || result.includes('Error')) {
							cy.readFile(Cypress.env('cycleIdFile')).then(cycleId => {
								if(cycleId != undefined ) {
									ZAPI.reportTestResultToZephyr(Cypress.env('apiBaseURL'), cycleId, Cypress.env('jiraProjectId'), issueKey, intTestResult);
								} else {
									cy.writeFile(Cypress.env('errorFilePath'), issueKey + "\tCycleId is neither defined at Test level nor the cycle id found in file "+Cypress.env('cycleIdFile')+"\n",{ flag: 'a+' });
								}
							});
						}
						else {
							ZAPI.reportTestResultToZephyr(Cypress.env('apiBaseURL'), result, Cypress.env('jiraProjectId'), issueKey, intTestResult);
						}
					})
				}
			})
		})
	}
})

before(() => {
	Cypress.on('uncaught:exception', (err, runnable) => {
		throw err
	})
	cy.writeFile(Cypress.env('errorFilePath'), "Date:: "+Date.now()+"\n");
	if(!Cypress.env('dryRun')) {
		if(Cypress.env('cloneCycle')) {
			cy.task('readFileMaybe', Cypress.env('cycleIdFile')).then((textOrNull) => {
				if(textOrNull == null) {
					ZAPI.cloneCycleForExecution(Cypress.env('apiBaseURL'), Cypress.env('cycleIdToBeClone'), Cypress.env('jiraProjectId'));
				}
			})
		}
	}
})

after(() => {
	
})

Add base.js to cypress\support\index.js

import './base'

cypress\plugins\index.js

const fs = require('fs')
const path = require('path');

module.exports = (on, config) => {
  on('task', {
    readFileMaybe (filename) {
      if (fs.existsSync(filename)) {
        return fs.readFileSync(filename, 'utf8')
      }

      return null
    },
	getZapiPackagePath() {
		return path.dirname(require.resolve("cypress-zapi-util/package.json"));
	}
  })
};

Example for taking screenshot and uploading


var ZAPI = require('cypress-zapi-util');

it('Issue: WDX-496 ~ Should do something2', () => {
	console.log(Cypress.env('baseUrl'));
	cy.screenshot('filename');
	ZAPI.attachCustomFiles(Cypress.mocha.getRunner().test.title, "filename");
})

Example for getting duplicate test cases in cycle folders

CycleFoldersScanReportForDuplicateTestCases.txt will be generated under user's Download folder


var ZAPI = require('cypress-zapi-util');

it('Issue: WDX-726, CycleId: 3581 ~ Should do something1', () => {
	ZAPI.getDuplicateTestCasesInCycleFolders("2922", "17910", "28921"); //cycleId, projectId, versionId
})
it('Issue: WDX-725 ~ Should do something1', () => {
	ZAPI.getDuplicateTestCasesInCycleFolders("2922", "17910", "28921"); //cycleId, projectId, versionId
})