From hubvue-fe-analysis-skills
Intelligent unit test generator for frontend projects that detects existing test frameworks and generates comprehensive tests for functions, components, and modules. Use when you need to: (1) Add unit tests to existing codebases, (2) Set up testing infrastructure for new projects, (3) Generate test cases for specific functions or components, (4) Ensure architectural consistency in testing approach across projects. Supports Jest, Vitest, Mocha with React, Vue, Angular frameworks.
How this skill is triggered — by the user, by Claude, or both
Slash command
/hubvue-fe-analysis-skills:unit-test-generatorThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
An intelligent assistant for creating and managing unit tests in frontend projects. This skill automatically detects your project's testing setup and generates appropriate, framework-consistent test code.
An intelligent assistant for creating and managing unit tests in frontend projects. This skill automatically detects your project's testing setup and generates appropriate, framework-consistent test code.
npm install
Generate tests for any file or component:
node scripts/detect-test-framework.js /path/to/project
node scripts/generate-test.js src/components/Button.js
Automatically identifies your project's testing stack:
Maintains your project's existing testing patterns:
const TestFrameworkDetector = require('./scripts/detect-test-framework');
const detector = new TestFrameworkDetector('./my-project');
const analysis = detector.detect();
console.log(analysis);
// Output: Frameworks, utilities, config files, recommendations
const TestGenerator = require('./scripts/generate-test');
const generator = new TestGenerator('./my-project', {
framework: 'jest',
react: true
});
const result = generator.generateForFile('src/components/Button.jsx');
// Returns: { testPath, testContent, analysis }
const TestConfigGenerator = require('./scripts/setup-test-config');
const config = new TestConfigGenerator('./my-project', 'jest', {
react: true,
typescript: true,
coverage: true
});
const files = config.writeConfigs(); // Creates config files
const deps = config.getDependencies(); // Returns required packages
describe('Button', () => {
it('renders without crashing', () => {
render(<Button />);
expect(screen.getByRole('button')).toBeInTheDocument();
});
it('handles click events', async () => {
const handleClick = jest.fn();
render(<Button onClick={handleClick} />);
await userEvent.click(screen.getByRole('button'));
expect(handleClick).toHaveBeenCalled();
});
});
describe('Button', () => {
it('renders without crashing', () => {
const wrapper = mount(Button);
expect(wrapper.exists()).toBe(true);
});
it('emits click event', async () => {
const wrapper = mount(Button);
await wrapper.trigger('click');
expect(wrapper.emitted('click')).toBeTruthy();
});
});
describe('formatCurrency', () => {
it('formats numbers correctly', () => {
expect(formatCurrency(1234.56)).toBe('$1,234.56');
});
it('handles edge cases', () => {
expect(formatCurrency(null)).toBe('$0.00');
expect(formatCurrency(0)).toBe('$0.00');
});
});
{
framework: 'jest' | 'vitest' | 'mocha', // Test framework
assertionStyle: 'expect' | 'assert', // Assertion style
includeMocks: true, // Include mock generation
testType: 'unit' | 'integration' | 'e2e', // Test type
coverage: true, // Include coverage
environment: 'jsdom' | 'node' // Test environment
}
.test.js or .spec.js suffixdescribe blocks# Already has Jest configured
node scripts/generate-test.js src/components/Button.jsx
# Setup Vitest
node scripts/setup-test-config.js vitest '{"vue": true}'
# Generate tests
node scripts/generate-test.js src/components/Button.vue
# Detect setup
node scripts/detect-test-framework.js .
# Add new tests
node scripts/generate-test.js src/utils/format.js '{"framework": "mocha"}'
Executable Node.js scripts for test generation and configuration:
detect-test-framework.js - Analyzes existing testing setupgenerate-test.js - Creates test files from source codesetup-test-config.js - Generates testing configuration filesComprehensive documentation and guides:
Template files for common testing scenarios:
Guides completion of development work by verifying tests, detecting environment, and presenting structured options for merge, PR, or cleanup.
Enforces test-driven development: write failing test first, then minimal code to pass. Use when implementing features or bugfixes.
Guides creation and editing of skills using test-driven development with pressure scenarios and subagents to verify agent compliance.
npx claudepluginhub joshuarweaver/cascade-code-general-misc-3 --plugin hubvue-fe-analysis-skills