For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt, and this page is available as Markdown at /config/test/federation.md.
close
  • English
  • 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.

    CLI
    rstest.config.ts
    npx rstest --federation

    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.

    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.

    rstest.config.ts
    import { federation } from '@module-federation/rstest';
    import { defineConfig } from '@rstest/core';
    
    export default defineConfig({
      plugins: [
        federation({
          name: 'main_app',
          remotes: {
            'component-app': 'component_app@http://localhost:3001/remoteEntry.cjs',
          },
          shared: {
            react: { singleton: true },
          },
        }),
      ],
    });

    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.