Intelligent unit test generator for frontend projects that detects existing test frameworks and generates comprehensive tests for functions, components, and modules...
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: