|
|
|
@ -7,9 +7,23 @@ Cypress.Screenshot.defaults({ |
|
|
|
|
|
|
|
|
|
const COMMAND_DELAY = 1000; |
|
|
|
|
|
|
|
|
|
function delay(ms) { |
|
|
|
|
let now = Date.now(); |
|
|
|
|
const end = now + ms; |
|
|
|
|
|
|
|
|
|
do { |
|
|
|
|
now = Date.now(); |
|
|
|
|
} while (now < end); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (Cypress.env('SLOWMO')) { |
|
|
|
|
const commandsToModify = ['clear', 'click', 'contains', 'reload', 'then', 'trigger', 'type', 'visit']; |
|
|
|
|
Cypress.Commands.overwriteQuery('contains', function (contains, filter, text, userOptions = {}) { |
|
|
|
|
delay(COMMAND_DELAY); |
|
|
|
|
const call = contains.bind(this); |
|
|
|
|
return call(filter, text, userOptions); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
const commandsToModify = ['clear', 'click', 'reload', 'then', 'trigger', 'type', 'visit']; |
|
|
|
|
commandsToModify.forEach((command) => { |
|
|
|
|
// @ts-ignore -- https://github.com/cypress-io/cypress/issues/7807
|
|
|
|
|
Cypress.Commands.overwrite(command, (originalFn, ...args) => { |
|
|
|
@ -65,3 +79,10 @@ beforeEach(() => { |
|
|
|
|
cy.setLocalStorage('grafana.featureToggles', toggles.join(',')); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
afterEach(() => { |
|
|
|
|
// in slowmo mode, wait to see the last command
|
|
|
|
|
if (Cypress.env('SLOWMO')) { |
|
|
|
|
cy.wait(COMMAND_DELAY); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|