grafana/packages/grafana-test-utils
Tom Ratcliffe 053920b8b7
Dashboards: Migrate DashList panel to use grafanaSearcher (#111274)
2025-09-24 10:35:40 +01:00
..
src Dashboards: Migrate DashList panel to use grafanaSearcher (#111274) 2025-09-24 10:35:40 +01:00
CHANGELOG.md
LICENSE_APACHE2
README.md
jest-setup.js
jest.config.js
package.json Release: Bump version to 12.3.0-pre (#110974) 2025-09-12 17:54:11 +00:00
project.json
tsconfig.json Chore: Remove @grafana/tsconfig (#109186) 2025-08-06 15:34:34 +01:00

README.md

Grafana test utils

This package is a collection of test utils and a mock API (using MSW) for use with core Grafana UI development.

Matchers

To add the matchers to your Jest config, import them then extend expect. This should be done in the setupFilesAfterEnv file declared in jest.config.{js,ts}.

// setupTests.ts
import { matchers } from '@grafana/test-utils';

expect.extend(matchers);

Included in this package are the following matchers:

toEmitValues

Tests that an Observable emits the expected values in the correct order. This matcher collects all emitted values (including errors) and compares them against the expected array using deep equality.

toEmitValuesWith

Tests that an Observable emits values that satisfy custom expectations. This matcher collects all emitted values and passes them to a callback function where you can perform custom assertions.