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

custom-commands-for-cypress

v3.0.1

Published

Cypress custom methods

Downloads

588

Readme

Utility Functions with Axios

This repository contains utility functions that leverage the Axios library to perform various tasks. These functions can be used in projects that require HTTP requests and other related operations.

Installation

To use the utility functions in your project, follow these steps:

  1. Install Axios if you haven't already:
npm install axios --save

2. Import the required functions into your project:

import {
  fetchOTP,
  newEmail,
  newPassword,
  updateAccountList,
  generateRandomString,
  APIReqWithCreateBody,
  APIReqWithParams,
  APITokenGenerator,
} from 'axios-utilities';


Utility Functions

fetchOTP
This function retrieves the OTP (One-Time Password) from a specific API endpoint. It makes use of the Axios library to perform HTTP requests.
// Example usage
fetchOTP()
  .then((otp) => {
    console.log('OTP:', otp);
  })
  .catch((error) => {
    console.error('Error fetching OTP:', error);
  });


newEmail
This function generates a new email address with the format QA{randomNumber}@example.testinator.com.
// Example usage
const email = newEmail();


newPassword
This function generates a random password with at least one special character, one uppercase letter, one lowercase letter, and one number.
// Example usage
const password = newPassword();


updateAccountList
This function updates the account list in a specified JSON file with a new email and password. The JSON file should contain an array of existing accounts.
// Example usage
const email = '[email protected]';
const password = 'password123';
updateAccountList(email, password);


generateRandomString
This function generates a random string of a specified length, which can be useful for generating random data or test cases.
// Example usage
const randomString = generateRandomString(10);


APIReqWithCreateBody
This function performs an API request with a request body. It allows you to specify the HTTP method, URL, headers, request body, and a flag to indicate whether to fail on status code.
// Example usage
const httpMethod = 'POST';
const url = 'https://api.example.com/resource';
const headers = { 'Content-Type': 'application/json' };
const requestBody = { key: 'value' };
const failOnStatusCode = true;

APIReqWithCreateBody(httpMethod, url, headers, requestBody, failOnStatusCode)
  .then(() => {
    console.log('API request with create body successful.');
    console.log('API response:', process.env.ApiRes);
  })
  .catch((error) => {
    console.error('API request with create body failed:', error);
  });


APIReqWithParams
This function performs an API request with query parameters. It allows you to specify the HTTP method, URL, headers, query parameters, and a flag to indicate whether to fail on status code.
// Example usage
const httpMethod = 'GET';
const url = 'https://api.example.com/resource';
const headers = { 'Content-Type': 'application/json' };
const queryParams = { page: 1, limit: 10 };
const failOnStatusCode = true;

APIReqWithParams(httpMethod, url, headers, queryParams, failOnStatusCode)
  .then(() => {
    console.log('API request with parameters successful.');
    console.log('API response:', process.env.GetApiRes);
  })
  .catch((error) => {
    console.error('API request with parameters failed:', error);
  });


APITokenGenerator
This function generates an API token by making a POST request to a specific URL with the required parameters. It is commonly used for authentication purposes.
// Example usage
APITokenGenerator()
  .then(() => {
    console.log('API token generated successfully.');
    console.log('Token response:', process.env.token_res);
  })
  .catch((error) => {
    console.error('API token generation failed:', error);
  });

  
Contributing
Contributions to this repository are welcome! If you have any suggestions, bug fixes, or additional utility functions to share, please feel free to open an issue or submit a pull request.