Grafana End-to-End Test Library built on Cypress with structured API for testing Grafana dashboards, data sources, panels, and administrative functions
—
Pending
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Pending
The risk profile of this skill
Structured test scenario creation with automatic setup, cleanup, and context management for organizing complex Grafana e2e test suites.
Creates structured e2e test scenarios with automatic hooks for setup and cleanup.
/**
* Creates structured e2e test scenarios with automatic hooks
* @param args - Scenario configuration object
*/
function e2eScenario(args: ScenarioArguments): void;
interface ScenarioArguments {
/** Test suite name (describe block) */
describeName: string;
/** Test case name (it block) */
itName: string;
/** Test implementation function */
scenario: () => void;
/** Skip execution if true */
skipScenario?: boolean;
/** Auto-add data source for test (default: false) */
addScenarioDataSource?: boolean;
/** Auto-add dashboard for test (default: false) */
addScenarioDashBoard?: boolean;
/** Use API login instead of UI (default: true) */
loginViaApi?: boolean;
}Usage Examples:
import { e2e } from "@grafana/e2e";
// Basic scenario
e2e.scenario({
describeName: "Dashboard Tests",
itName: "should create a dashboard",
scenario: () => {
e2e.flows.addDashboard();
e2e.pages.Dashboard.url().should("be.visible");
}
});
// Scenario with auto-setup
e2e.scenario({
describeName: "Panel Tests",
itName: "should add panel to dashboard",
addScenarioDashBoard: true,
scenario: () => {
e2e.flows.addPanel({
visualization: "Table",
panelTitle: "Test Panel"
});
e2e.components.Panels.Panel.title("Test Panel").should("be.visible");
}
});
// Scenario with data source setup
e2e.scenario({
describeName: "Data Source Tests",
itName: "should configure data source",
addScenarioDataSource: true,
loginViaApi: false, // Use UI login
scenario: () => {
// Test logic here - data source is automatically available
e2e.pages.DataSources.url().should("contain", "/datasources");
}
});Functions for managing test scenario state and cleanup tracking.
/**
* Get current scenario context with cleanup information
* @returns Current scenario context
*/
function getScenarioContext(): ScenarioContext;
/**
* Update scenario context with partial data
* @param context - Partial context data to merge
*/
function setScenarioContext(context: Partial<ScenarioContext>): void;
interface ScenarioContext {
/** Dashboards created during test for cleanup */
addedDashboards: DeleteDashboardConfig[];
/** Data sources created during test for cleanup */
addedDataSources: DeleteDataSourceConfig[];
/** Title of last dashboard added */
lastAddedDashboard: string;
/** UID of last dashboard added */
lastAddedDashboardUid: string;
/** Name of last data source added */
lastAddedDataSource: string;
/** ID of last data source added */
lastAddedDataSourceId: string;
/** Flag indicating user preferences were changed */
hasChangedUserPreferences: boolean;
}Usage Examples:
import { e2e } from "@grafana/e2e";
// Get current context
const context = e2e.getScenarioContext();
console.log("Last dashboard:", context.lastAddedDashboard);
// Update context
e2e.setScenarioContext({
lastAddedDashboard: "My Test Dashboard",
hasChangedUserPreferences: true
});
// Access context in test
e2e.scenario({
describeName: "Context Tests",
itName: "should track dashboard creation",
scenario: () => {
e2e.flows.addDashboard({ title: "Test Dashboard" });
const context = e2e.getScenarioContext();
expect(context.lastAddedDashboard).to.equal("Test Dashboard");
expect(context.addedDashboards).to.have.length.greaterThan(0);
}
});The scenario system automatically tracks resources created during tests:
addedDashboards array for cleanupaddedDataSources array for cleanuphasChangedUserPreferences flagUse e2e.flows.revertAllChanges() to clean up all tracked resources at the end of tests.