@@ -7,9 +7,23 @@ Cypress.Screenshot.defaults({
|
||||
|
||||
const COMMAND_DELAY = 1000;
|
||||
|
||||
if (Cypress.env('SLOWMO')) {
|
||||
const commandsToModify = ['clear', 'click', 'contains', 'reload', 'then', 'trigger', 'type', 'visit'];
|
||||
function delay(ms) {
|
||||
let now = Date.now();
|
||||
const end = now + ms;
|
||||
|
||||
do {
|
||||
now = Date.now();
|
||||
} while (now < end);
|
||||
}
|
||||
|
||||
if (Cypress.env('SLOWMO')) {
|
||||
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);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -164,6 +164,8 @@ case "$1" in
|
||||
;;
|
||||
"dev")
|
||||
echo "Dev mode"
|
||||
# remove comment to run in slomo ( demo mode )
|
||||
# env[SLOWMO]=1
|
||||
CMD="cypress open"
|
||||
enterpriseSuite=$(basename "${args[2]}")
|
||||
;;
|
||||
|
||||
Reference in New Issue
Block a user