Error: No browsers were started. Browser launcher configuration
0 reputation · 12 Nov 2023, 03:38 UTC
0 reputation · 12 Nov 2023, 03:38 UTC
To execute a test suite across multiple browsers using Karma, but the run aborts with the message "No browsers were started. Did you forget to install the browser launcher?" when a referenced launcher is missing.
Karma validates the browsers array against installed launcher plugins (e.g., karma-chrome-launcher). The current implementation merely reports the error and exits; it does not attempt to auto‑install missing binaries. When multiple browsers are listed, the presence of a single missing launcher aborts the entire run, even if other launchers are available.
It is unclear whether Karma should provide an automatic fallback to download or install the required browser binary when a launcher is referenced but not installed, and how to configure selective failure for individual launchers.
31775 reputation · 12 Nov 2023, 07:06 UTC
Karma does not auto‑install missing browser binaries and provides no flag to skip a single unavailable launcher; the run stops as soon as any entry in the browsers array cannot be matched to an installed launcher plugin.
The error appears when Karma resolves each name in browsers against the launcher plugins it has loaded (e.g., karma-chrome-launcher, karma-firefox-launcher). If a name has no matching plugin—or the plugin exists but the underlying browser binary cannot be found—Karma treats the whole configuration as invalid and exits.
browsers array dynamically, filtering out names whose launchers or binaries are not present.npm ls karma-<browser>-launcher (or check package.json).plugins array in karma.conf.js, make sure the missing launcher is listed there; otherwise Karma will not auto‑load it.which google-chrome or the CHROME_BIN environment variable).browsers list with a dynamic one, for example:const fs = require('fs');
function hasLauncher(name) {
try {
return require.resolve(`karma-${name}-launcher`);
} catch (_) {
return false;
}
}
function binaryExists(path) {
try {
return fs.existsSync(path) && fs.statSync(path).isFile();
} catch (_) {
return false;
}
}
const desired = ['Chrome', 'Firefox'];
const browsers = desired.filter(name => {
const launcher = hasLauncher(name.toLowerCase());
const bin = process.env[`${name.toUpperCase()}_BIN`] || (
name.toLowerCase() === 'chrome' ? '/usr/bin/google-chrome' :
name.toLowerCase() === 'firefox' ? '/usr/bin/firefox' : null
);
return launcher && (bin ? binaryExists(bin) : true);
});
module.exports = function(config) {
config.set({
// … other config …
browsers,
// …
});
};
Are you explicitly defining the plugins array in your karma.conf.js? Knowing this determines whether you need to add the missing launcher to that array or simply install the plugin via npm.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.