Rstest types
Rstest exports its public TypeScript types from @rstest/core. Use import type so these imports are erased from runtime output.
Configuration types
Use these types when you need to type a config object, a config factory, or shared config utilities outside defineConfig.
RstestConfig: The top-level Rstest configuration type.RstestConfigSyncFn: A synchronous function that returnsRstestConfig.RstestConfigAsyncFn: An asynchronous function that returnsRstestConfig.RstestConfigExport: The union accepted by a Rstest config file.ProjectConfig: The type for a standalone Rstest Project config.
For most config files, prefer defineConfig, defineProject, and defineInlineProject because they preserve autocomplete without requiring explicit annotations.
Test API types
Use these types when extending test APIs, defining reusable helpers, or typing custom fixtures.
TestContext is available as a public type export starting in Rstest 0.10.1.
Rstest: The full runtime API shape, includingtest,describe,expect, hooks, andrstestutilities.RstestUtilities: The type of therstestandrsutility objects.TestContext: The context object passed to test callbacks and lifecycle hooks.Describe: The type of thedescribeAPI.Expect: The assertion type returned byexpect(value).ExpectStatic: The callableexpectAPI type.
Mock types
Use mock types when a helper accepts mock functions, spies, or mocked modules.
Mock
Mock<T> represents a callable mock function created by rstest.fn. It preserves the parameters and return type of T while adding mock control APIs.
MockInstance
MockInstance<T> represents the shared mock control API on both rstest.fn() mocks and rstest.spyOn() spies. Use it when a helper only needs mock methods such as mockClear, mockReset, or mockRestore and does not need to call the mock function directly.
When you create a mock or spy inline, you usually do not need to annotate it because TypeScript can infer the type.
Mocked
Mocked<T> wraps an object or module type so its methods are typed as mocks. This is useful after rstest.mock, rstest.mockObject, or rstest.mocked.
Reporter and result types
Use these types when creating custom reporters or external tools that consume Rstest results.
For reporter implementation details, see Reporter.
Assertion types
Use Assertion or ExpectStatic when typing custom assertion helpers.
Rsbuild type
Rstest re-exports Rspack from @rsbuild/core for integrations that need to type Rsbuild or Rspack hooks while staying on the same dependency graph as Rstest.