57 lines
1.8 KiB
JavaScript
57 lines
1.8 KiB
JavaScript
// ***********************************************************
|
|
// Diese Datei wird automatisch geladen, bevor Tests ausgeführt werden.
|
|
//
|
|
// Dies ist ein guter Platz für globale Konfigurationen
|
|
// und Änderungen, die Cypress beeinflussen.
|
|
//
|
|
// Weitere Infos: https://on.cypress.io/configuration
|
|
// ***********************************************************
|
|
|
|
// Importiere zusätzliche Befehle
|
|
import "./commands";
|
|
|
|
// Alternativ: CommonJS-Syntax verwenden
|
|
// require('./commands')
|
|
|
|
// Verstecke unnötige Logs für XHR- und Fetch-Anfragen
|
|
const app = window.top;
|
|
if (!app.document.head.querySelector("[data-hide-command-log-request]")) {
|
|
const style = app.document.createElement("style");
|
|
style.innerHTML = `
|
|
.command-name-request, .command-name-xhr {
|
|
display: none; /* Verstecke Fetch- und XHR-Logs */
|
|
}
|
|
.runnable-pass .collapsible-header {
|
|
display: none; /* Verstecke den Header erfolgreicher Tests */
|
|
}
|
|
`;
|
|
style.setAttribute("data-hide-command-log-request", "");
|
|
app.document.head.appendChild(style);
|
|
}
|
|
|
|
// Globale Ereignisse für Cypress konfigurieren
|
|
Cypress.on("test:after:run", (test, runnable) => {
|
|
// Minimiert die Logs für erfolgreiche Tests
|
|
if (test.state === "passed") {
|
|
runnable._testConfigBody = null; // Löscht den Test Body
|
|
}
|
|
});
|
|
|
|
// Schließe automatisch erfolgreiche Tests in der GUI
|
|
Cypress.on("log:added", (log) => {
|
|
if (log.state === "passed") {
|
|
log.displayName = ""; // Versteckt Log-Details für erfolgreiche Schritte
|
|
}
|
|
});
|
|
|
|
// Screenshot nach jedem fehlgeschlagenen Test
|
|
Cypress.on("fail", (error, runnable) => {
|
|
cy.screenshot(`error-${runnable.title}`); // Screenshot für Fehler erstellen
|
|
throw error; // Fehler weitergeben
|
|
});
|
|
|
|
// Logge die Dauer jedes Tests
|
|
Cypress.on("test:after:run", (test) => {
|
|
cy.log(`Test "${test.title}" abgeschlossen in ${test.duration} ms`);
|
|
});
|