Every framework adapter, launcher, reporter, and preprocessor you've used so far is actually a Karma plugin. This lesson explains how Karma discovers and loads plugins, and when you need to list them explicitly.
Automatic Plugin Discovery
By default, Karma automatically loads every installed npm package whose name starts with karma- and lives in your project's dependencies. This is why installing karma-jasmine and listing 'jasmine' in frameworks just works, without ever mentioning karma-jasmine explicitly anywhere in your config.
This convention-based discovery is convenient for typical projects, but large monorepos or projects with many unrelated karma-* packages installed sometimes want tighter, explicit control — that's what the plugins option provides.
// No explicit "plugins" option needed for typical setups —
// installing karma-jasmine and karma-chrome-launcher is enough:
config.set({
frameworks: ['jasmine'],
browsers: ['ChromeHeadless']
});
Karma scans installed packages named karma-* automatically; this example needs no plugins array at all.
In a monorepo with dozens of packages, automatic discovery can accidentally load unrelated karma-* plugins from a sibling package's dependencies, occasionally causing subtle conflicts. Listing plugins explicitly makes the configuration self-documenting and immune to unrelated dependency changes elsewhere in the repo.
Improves clarity — every plugin dependency is visible directly in karma.conf.js.
Prevents accidental loading of unrelated karma-* packages from elsewhere in a monorepo.
Makes it obvious, during code review, exactly what a config change requires installing.
Requires discipline: every new framework/launcher/reporter addition must also be added here.
The Shape of a Custom Plugin
A Karma plugin is ultimately just an object whose keys follow a type:name convention, mapping to factory functions. You'll see this exact shape again when writing custom launchers, reporters, or preprocessors later in this course.
Published karma-* npm packages export exactly this shape; local plugins can too.
Common Mistakes
Adding an explicit plugins array but forgetting to include a plugin your config still relies on.
Assuming a plugin is 'installed and working' just because npm install succeeded, without confirming Karma actually loaded it.
Not recognizing 'Unknown launcher' or 'Unknown framework' errors as plugin-loading problems.
Publishing or sharing a custom plugin without following the karma- naming convention, breaking auto-discovery for consumers.
Key Takeaways
Karma automatically discovers and loads any installed karma-* npm package by default.
An explicit plugins array disables auto-discovery and requires listing every needed plugin.
All Karma plugin types (frameworks, launchers, reporters, preprocessors) share the same underlying plugin object shape.
'Unknown launcher/framework/reporter' errors almost always trace back to a missing or unlisted plugin.
Pro Tip
If you're debugging an 'Unknown launcher' or similar error, run npm ls | grep karma- to see every Karma plugin actually installed. It's the fastest way to tell a missing-install problem apart from a config typo.
You now understand Karma's plugin system. Next, learn how the client option controls behavior inside the browser itself.