// *********************************************************** // This example support/index.js is processed and // loaded automatically before your e2e test files. // // This is a great place to put global configuration and // behavior that modifies Cypress. // // You can change the location of this file or turn off // automatically serving support files with the // 'supportFile' configuration option. // // You can read more here: // https://on.cypress.io/configuration // *********************************************************** import './commands'; function randomString(options = { length: 10 }) { let possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'; return randomizeValue(possible, options); } function randomNumber(options = { length: 10 }) { let possible = '0123456789'; return randomizeValue(possible, options); } function randomizeValue(characterSet, options) { return Array.from({ length: options.length }, () => characterSet.charAt(Math.floor(Math.random() * characterSet.length)), ).join(''); } const style = document.createElement('style'); style.innerHTML = ` * { transition: none !important; animation: none !important; } `; document.head.appendChild(style); const waitForApiReady = (url, maxRetries = 20, delay = 1000) => { let retries = 0; function checkApi() { return cy .request({ url, failOnStatusCode: false, }) .then((response) => { if (response.status !== 200 && retries < maxRetries) { retries++; cy.wait(delay); return checkApi(); } expect(response.status).to.eq(200); }); } return checkApi(); }; before(() => { waitForApiReady('/api/Applications/status'); }); export { randomString, randomNumber, randomizeValue };