extends
- Type:
ExtendConfig | ExtendConfigFn | (ExtendConfig | ExtendConfigFn)[] - Default:
undefined
The extends option allows you to extend your Rstest configuration from external sources, such as adapters that convert other build tools' configurations to Rstest-compatible format.
This enables:
- Adapter Integration: Extend from adapters like
@rstest/adapter-rslib - Async Configuration: Load configuration from external sources asynchronously
- Config Merging: Automatically merge extended configuration with your local Rstest config
- Composable Presets: Combine multiple shared configs in a single
extendsarray
Basic usage (object)
ExtendConfig is a plain subset of RstestConfig without projects.
You can use it to extend your Rstest configuration from external sources. Rstest will merge the extended config with your local config following the configuration merging rules.
Function usage
ExtendConfigFn is a function that takes the user's Rstest config as input and returns an extended config.
You can use this to load external configuration files, fetch remote configs, or conditionally modify the config based on user settings.
Multiple extends
You can pass an array to extends when you want to compose multiple presets.
Rstest resolves the array from left to right. Later entries override earlier ones, and your local config still has the highest priority.
When an entry is a function, each ExtendConfigFn is resolved independently against the original user config. Array order only affects merge precedence, not the input passed to each function.
Configuration merging
Rstest deep-merges object fields and overrides primitives. Local config always takes precedence over the extended config.
When extends is an array, precedence is:
Important merge rules:
- Primitive fields like
testTimeout,retry, andglobalsare overridden by the later value. setupFiles,globalSetup, andpluginsare concatenated so multiple presets can contribute entries.include,reporters, andcoverage.reportersare replaced by the later value.- Object fields like
source,resolve,output,tools,env, andcoverageare deep-merged. browseris shallow-merged, so later keys override earlier keys.projectsis ignored in every extended config.
Example:
Using adapters
Example: extend from Rslib config
Use the @rstest/adapter-rslib adapter to extend Rstest configuration from an existing Rslib config file. The adapter automatically maps compatible options like source.define, source.include, source.exclude, and more.
Limitations
The extends configuration cannot include the projects field. To define multiple projects, extend each project individually: