UNPKG

cypress-bootstrap

Version:

Cypress Bootstrap is a project scaffolding tool that sets up a Cypress automation framework with a standardized folder structure and Page Object Model (POM) design. It helps teams quickly start testing with built-in best practices and sample specs.

45 lines (41 loc) 1.46 kB
import { v4 as uuidv4 } from 'uuid'; class Utils { /** * Generate a random 7-digit ID number. * This ID is generated by creating a random number between 1000000 and 9999999. * @returns {string} A random 7-digit ID number as a string. * @example * const randomId = Utils.generateRandomIdNumber(); */ public generateRandomIdNumber() { return Math.floor(1000000 + Math.random() * 9000000).toString(); } /** * Generate a random string of specified length. * The string consists of uppercase letters, lowercase letters, and digits. * @param {number} length - The length of the random string to generate. * @returns {string} A random string of the specified length. * @example * const randomString = Utils.generateRandomString(10); */ public generateRandomString(length: number) { const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; let result = ''; for (let i = 0; i < length; i++) { const randomIndex = Math.floor(Math.random() * characters.length); result += characters.charAt(randomIndex); } return result; } /** * Generate a random GUID (Globally Unique Identifier). * This is a universally unique identifier that can be used for various purposes. * @returns {string} A random GUID. * @example * const guid = Utils.generateGuid(); */ public generateGuid() { return uuidv4(); } } export default new Utils();