grafana/grafana
@grafana/test-utils
Shared Jest helpers and mocks. Source under packages/grafana-test-utils/.
What's inside
- A Redux store factory (
getMockStore) that mirrors Grafana's real configuration so component tests can render a tree that depends on the global store. - Theme-aware
renderwrappers that wrap React Testing Library'srenderwith<ThemeProvider>,<I18nProvider>, and the appropriate router. - Common runtime mocks (
mockBackendSrv,mockDataSourceSrv,mockLocationService). - MSW server bootstrapping helpers for tests that need to intercept HTTP.
Usage
import { render, screen, mockBackendSrv } from '@grafana/test-utils';
it('renders', () => {
mockBackendSrv({ get: jest.fn().mockResolvedValue({}) });
render(<MyThing />);
expect(screen.getByText('Hello')).toBeInTheDocument();
});See also
- How to contribute / Testing.
@grafana/runtime— what the mocks override.
Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.