Skip to content
PluginStats

vitest-plugin-module-federation weekly downloads statistics

By chrisboakes · npm · Testing

Auto-mock Module Federation remote imports in Vitest — no more unresolvable 'remoteApp/Component' imports in unit tests.

View on npm Fresh · Dec 6, 2026

vitest-plugin-module-federation has 9 recorded weekly downloads on npm, an increase of 12.5% over the past 30 days, ranking #3161 of 3,247 tracked listings.

Weekly downloads
9
Official API · Dec 5, 2026
7-day growth
+12.5%
+1 weekly downloads
30-day growth
+12.5%
+1 weekly downloads
90-day growth
+50.0%
+3 weekly downloads
Rank
#3161
▼ 148 in 7 days

About vitest-plugin-module-federation

Vitest Plugin Module Federation

CI npm version

Vitest plugin to auto-mock Module Federation remote imports in unit tests.

The Problem

If your app consumes federated remotes, imports like shop/Button only exist at runtime:

Error: Failed to resolve import "shop/Button" from "src/Basket.tsx"

The usual fix is a vi.mock('shop/Button', ...) in every test file that touches a remote. That gets old quickly.

The Solution

Register the plugin once and tell it which remotes you have:

// vitest.config.ts
import { defineConfig } from 'vitest/config';
import moduleFederationMock from 'vitest-plugin-module-federation';

export default defineConfig({
	plugins: [
		moduleFederationMock({
			remotes: ['shop', 'checkout'],
		}),
	],
	test: {
		environment: 'jsdom',
	},
});

Anything imported from shop/* or checkout/* now resolves to a generated mock. By default that's a React component which renders its props and children with a predictable test id:

import Button from 'shop/Button';

render(<Button aria-label="checkout">Go</Button>);
screen.getByTestId('mock-shop-button');

No vi.mock calls and no changes to your components.

Requirements

  • Node.js >= 20
  • Vitest 2, 3 or 4 (it's a plain Vite plugin, so any Vite-based runner works)

Installation

pnpm

pnpm add -D vitest-plugin-module-federation

npm

npm install --save-dev vitest-plugin-module-federation

Usage

Telling the plugin about your remotes

Pass remote names directly, a RegExp, or reuse the federation config you already have. At least one of remotes or federationConfig is required and they merge when both are given:

moduleFederationMock({ remotes: ['shop', 'checkout'] });

// or match specifiers with a RegExp
moduleFederationMock({ remotes: /^apps_[a-z]+\// });

// or read the remote names from your Module Federation config
import { federationConfig } from './module-federation.config';
moduleFederationMock({ federationConfig });
Choosing the default mock

defaultMock controls what gets generated for a matched import:

  • 'react-component' (the default) renders <div data-testid="mock-<remote>-<module>" {...props}>{children}</div>. It's exported as default and as a PascalCased named export derived from the module path, so shop/user-profile also exports UserProfile. Note react needs to be installed; it isn't a dependency of this plugin.
  • 'empty' gives you export default {} with no React involved.
  • A function gives you full control and should return the module source:
moduleFederationMock({
	remotes: ['shop'],
	defaultMock: ({ remote, modulePath }) => `export default () => null;`,
});
Overriding individual modules

Sometimes a generated component isn't enough, for example a remote that exports utilities. Use mocks to override specific imports:

moduleFederationMock({
	remotes: ['shop', 'checkout'],
	mocks: {
		// inline module source, served as-is
		'checkout/config': `export const currency = 'GBP';`,

		// point the import at a real file (relative to the Vite root)
		'checkout/formatPrice': { file: './test/mocks/formatPrice.ts' },

		// keep the default mock but add named exports
		'shop/Header': { namedExports: ['HeaderNav'] },
	},
});
TypeScript

Your app probably declares its remote modules already. If not:

// remotes.d.ts
declare module 'shop/Button' {
	import type { ComponentType, PropsWithChildren } from 'react';
	const Button: ComponentType<PropsWithChildren<Record<string, unknown>>>;
	export default Button;
}

How it works

The plugin runs before Vite's own resolver (enforce: 'pre') and matches import specifiers against your remote names. Matches resolve to a virtual module (or to your file override) and the mock source is generated at load time. Because the interception happens at the resolver level, it makes no difference which bundler builds the app itself.

Credits

MIT © Chris Boakes

Description from the npm listing.

  • vitest
  • vitest-plugin
  • vite-plugin
  • module-federation
  • microfrontend
  • mock
  • testing

README badge

Show your rank in a README or on your website. The badge updates automatically.

Charts

Images: 30d · 1y · all time · 1600×900 dark

Adoption over time

vitest-plugin-module-federation weekly downloads on npm, last 90 days: 9 weekly downloads as of Dec 5, 2026, +50.0% over 90 days.vitest-plugin-module-federationWeekly downloads on npm · Last 90 days9downloads / week+50.0% over 90 days02468101214Sep 6Sep 21Oct 6Oct 21Nov 5Nov 20Dec 5downloads / weekobservedarchived (Internet Archive)no observationsSep 7, 2026 – Dec 5, 2026 · 90 observations · Updated Dec …pluginstats.com
vitest-plugin-module-federation weekly downloads on npm, last 90 days: 9 weekly downloads as of Dec 5, 2026, +50.0% over 90 days.

7/30/90-day growth

vitest-plugin-module-federation weekly downloads growth on npm: +12.5% over 7 days, +12.5% over 30 days, +50.0% over 90 days.vitest-plugin-module-federationWeekly downloads growth on npm9downloads / week now7-day growth+1 weekly downloads+12.5%30-day growth+1 weekly downloads+12.5%90-day growth+3 weekly downloads+50.0%Growth vs. nearest observation to each baseline date · Updated Dec 5, 2026pluginstats.com
vitest-plugin-module-federation weekly downloads growth on npm: +12.5% over 7 days, +12.5% over 30 days, +50.0% over 90 days.

Ranking history

vitest-plugin-module-federation npm ranking history: currently #3161 (by weekly downloads).vitest-plugin-module-federationnpm ranking · by weekly downloads · Last 90 days#3161current rank#2000#2200#2400#2600#2800#3000#3200Sep 7Sep 22Oct 7Oct 22Nov 6Nov 21Dec 6rankOct 18, 2026 – Dec 6, 2026 · 44 observations · Updated Dec 5, 2026pluginstats.com
vitest-plugin-module-federation npm ranking history: currently #3161 (by weekly downloads).

Listing placement

All npm3,247 listings · 163 pages · 1,083 shown · page 159, #3 (overall #3,163)
All npm: every listing in weekly downloads order

Listing placement

Testing26 listings · 2 pages · page 2, #2 (overall #22)
Testing: every listing in weekly downloads order

Filled points are observed values; hollow points come from Internet Archive snapshots of the listing page. Dashed segments span periods with no observations — values between points are not interpolated.

Each band is one page of 20. Weekly downloads on a linear scale. Placement is projected from weekly downloads, so it can differ from the marketplace's own sort order. Hover a dot to see the listing.

Recent observations

Full history (170)
Recent weekly downloads observations for vitest-plugin-module-federation
Date (UTC)Weekly downloadsChange vs. previous
9+1
80
8+3
5+1
40
4+1
3-5
80
8+2
6-1
70
70
70
7—

Data source

Weekly downloads (trailing 7 complete days) come from the official npm downloads API. Downloads include CI and mirrors and are not equivalent to installs or users. npm publishes no ratings.

Listing: https://www.npmjs.com/package/vitest-plugin-module-federation. First seen Oct 16, 2026; last successful collection Dec 6, 2026. See the methodology.