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 · Oct 18, 2026

vitest-plugin-module-federation has 1 recorded weekly downloads on npm, a decrease of 92.9% over the past 30 days, ranking #2312 of 2,322 tracked listings.

Weekly downloads
1
Official API · Oct 18, 2026
7-day growth
0.0%
0 weekly downloads
30-day growth
-92.9%
-13 weekly downloads
90-day growth
-87.5%
-7 weekly downloads
Rank
#2312
Among tracked npm listings

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: 1 weekly downloads as of Oct 18, 2026, -87.5% over 90 days.vitest-plugin-module-federationWeekly downloads on npm · Last 90 days1downloads / week-87.5% over 90 days024681012141618Jul 20Aug 4Aug 19Sep 3Sep 18Oct 3Oct 18downloads / weekobservedarchived (Internet Archive)no observationsJul 22, 2026 – Oct 18, 2026 · 89 observations · Updated Oc…pluginstats.com
vitest-plugin-module-federation weekly downloads on npm, last 90 days: 1 weekly downloads as of Oct 18, 2026, -87.5% over 90 days.

7/30/90-day growth

vitest-plugin-module-federation weekly downloads growth on npm: 0.0% over 7 days, -92.9% over 30 days, -87.5% over 90 days.vitest-plugin-module-federationWeekly downloads growth on npm1downloads / week now7-day growth+0 weekly downloads0.0%30-day growth-13 weekly downloads-92.9%90-day growth-7 weekly downloads-87.5%Growth vs. nearest observation to each baseline date · Updated Oct 18, 2026pluginstats.com
vitest-plugin-module-federation weekly downloads growth on npm: 0.0% over 7 days, -92.9% over 30 days, -87.5% over 90 days.

Ranking history

vitest-plugin-module-federation npm ranking history: currently #2312 (by weekly downloads).vitest-plugin-module-federationnpm ranking · by weekly downloads · Last 90 days#2312current rank#2240#2250#2260#2270#2280#2290#2300#2310#2320Jul 22Aug 6Aug 21Sep 5Sep 20Oct 5Oct 20rankOct 18, 2026 – Oct 20, 2026 · 3 observations · Updated Oct 18, 2026pluginstats.com
vitest-plugin-module-federation npm ranking history: currently #2312 (by weekly downloads).

Listing placement

All npm2,320 listings · 116 pages · 1,162 shown · page 116, #16 (overall #2,316)
All npm: every listing in weekly downloads order

Listing placement

Testing21 listings · 2 pages · page 2, #1 (overall #21)
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 (122)
Recent weekly downloads observations for vitest-plugin-module-federation
Date (UTC)Weekly downloadsChange vs. previous
1+1
0-1
10
10
10
10
10
10
1-1
2-1
30
3-1
40
4—

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 Oct 20, 2026. See the methodology.