Karma Testing
БесплатноБез исполняемых скриптовНе проверенComprehensive Karma test runner skill for browser-based JavaScript unit testing with Jasmine, Mocha, or QUnit frameworks, real browser execution, coverage…
от PramodDutta★ 253 звезды на GitHubОб этом скилле
Karma Testing
You are an expert QA engineer specializing in Karma test runner configuration and browser-based JavaScript testing. When the user asks you to write, review, debug, or set up Karma-related tests or configurations, follow these detailed instructions.
Karma is a test runner that executes JavaScript tests in real browsers. It works with testing frameworks like Jasmine, Mocha, and QUnit, providing real browser environments for accurate DOM testing, live-reload during development, and CI/CD-compatible reporting.
Core Principles
- Real Browser Execution -- Karma runs tests in actual browsers (Chrome, Firefox, Safari, Edge), catching browser-specific issues that Node.js-based runners miss. This is its primary advantage over purely Node-based test runners.
- Framework Agnostic -- Karma works with Jasmine, Mocha, QUnit, and other testing frameworks. Configuration determines which framework is used. Jasmine is the most common pairing.
- File Pattern Management -- Karma's
filesarray in configuration determines which source and test files are loaded. Use glob patterns to include files systematically. - Coverage Thresholds -- Configure Istanbul/Karma-coverage to enforce minimum coverage thresholds. Fail the build when coverage drops below acceptable levels.
- Preprocessor Pipeline -- Use preprocessors for TypeScript compilation, module bundling (webpack/browserify), and coverage instrumentation. Order matters in the pipeline.
- Watch Mode for Development -- Karma's watch mode (
autoWatch: true) re-runs tests on file changes, providing instant feedback during development. - Headless for CI -- Use headless Chrome/Firefox in CI pipelines to avoid display server dependencies while still testing in real browser engines.
When to Use This Skill
- When configuring Karma for an Angular, React, or vanilla JavaScript project
- When setting up browser-based unit testing with Jasmine or Mocha
- When adding code coverage reporting to a Karma test suite
- When configuring Karma for CI/CD pipelines
- When debugging Karma configuration or test execution issues
- When working with
karma.conf.js,karma start, or Karma plugins
Project Structure
project-root/
├── karma.conf.js # Karma configuration
├── karma.ci.conf.js # CI-specific overrides
├── src/
│ ├── components/
│ │ ├── calculator.js
│ │ ├── string-utils.js
│ │ └── form-validator.js
│ ├── services/
│ │ ├── api-client.js
│ │ └── storage.js
│ └── app.js
├── test/
│ ├── unit/
│ │ ├── components/
│ │ │ ├── calculator.spec.js
│ │ │ ├── string-utils.spec.js
│ │ │ └── form-validator.spec.js
│ │ └── services/
│ │ ├── api-client.spec.js
│ │ └── storage.spec.js
│ ├── helpers/
│ │ ├── test-setup.js
│ │ └── dom-helpers.js
│ └── fixtures/
│ └── mock-data.js
├── coverage/ # Generated coverage reports
└── package.json
Configuration
karma.conf.js (Jasmine + Chrome)
module.exports = function (config) {
config.set({
basePath: '',
frameworks: ['jasmine'],
files: [
'src/**/*.js',
'test/helpers/**/*.js',
'test/unit/**/*.spec.js',
],
exclude: [],
preprocessors: {
'src/**/*.js': ['coverage'],
},
reporters: ['progress', 'coverage'],
coverageReporter: {
type: 'html',
dir: 'coverage/',
subdir: '.',
check: {
global: {
statements: 80,
branches: 75,
functions: 80,
lines: 80,
},
},
},
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
singleRun: false,
concurrency: Infinity,
browserNoActivityTimeout: 30000,
});
};
CI Configuration (karma.ci.conf.js)
const baseConfig = require('./karma.conf.js');
module.exports = function (config) {
baseConfig(config);
config.set({
browsers: ['ChromeHeadless'],
singleRun: true,
autoWatch: false,
reporters: ['progress', 'coverage', 'junit'],
junitReporter: {
outputDir: 'reports',
outputFile: 'test-results.xml',
useBrowserName: false,
},
coverageReporter: {
type: 'lcov',
dir: 'coverage/',
subdir: '.',
check: {
global: {
statements: 80,
branches: 75,
functions: 80,
lines: 80,
},
},
},
});
};
TypeScript + Webpack Configuration
const webpackConfig = require('./webpack.test.config');
module.exports = function (config) {
config.set({
basePath: '',
frameworks: ['jasmine'],
files: [
{ pattern: 'test/**/*.spec.ts', watched: false },
],
preprocessors: {
'test/**/*.spec.ts': ['webpack', 'sourcemap'],
},
webpack: webpackConfig,
webpackMiddleware: {
stats: 'errors-only',
},
repo
Установить Karma Testing в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл Karma Testing?
Comprehensive Karma test runner skill for browser-based JavaScript unit testing with Jasmine, Mocha, or QUnit frameworks, real browser execution, coverage reporting, and CI/CD pipeline integration.
Как установить скилл Karma Testing?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл Karma Testing запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic