federation
- Type:
boolean - Default:
false - CLI:
--federation
Whether to enable Module Federation support.
Rstest supports Module Federation in both Node Mode (including DOM-simulated environments such as jsdom) and Browser Mode.
When enabled, Rstest installs runtime shims in the test worker so that a Module Federation runtime can load remote entries and chunks through Rstest's module loader while module mocks stay effective.
Testing a federated app
federation only turns on Rstest's test runtime support; it does not configure remotes, exposes, or shared modules. When you use @module-federation/rstest, the plugin configures the Module Federation build and automatically enables Rstest's compatibility mode for Node-based test environments, so you do not need to set federation: true again there.
In Browser Mode the plugin does not turn on the federation option. However, globalSetup files always run in a Node process, and their build output carries the same federation runtime, which throws on load without the switch. Set federation: true yourself whenever a Browser Mode project uses globalSetup.
Start with the Module Federation guide for installation and the Rstest testing workflow. See the official Rstest integration guide for reusing an Rsbuild federation configuration and the complete plugin options.
This Node-based example consumes a Node-targeted remoteEntry.cjs. Browser Mode should consume the browser build's remoteEntry.js. See the Module Federation guide for the distinction and the Node and Browser examples for complete setups.