Loading...
Loading...
Generates test code from specifications, components, and API endpoints. Creates unit tests, integration tests, and E2E tests following project testing patterns and conventions.
npx skill4agent add oimiragieo/agent-studio test-generatorimport { render, screen, waitFor } from '@testing-library/react'
import { describe, it, expect, vi } from 'vitest'
import { UserProfile } from './user-profile'
describe('UserProfile', () => {
it('renders user information', async () => {
const mockUser = { id: '1', name: 'John', email: 'john@example.com' }
render(<UserProfile user={mockUser} />)
await waitFor(() => {
expect(screen.getByText('John')).toBeInTheDocument()
expect(screen.getByText('john@example.com')).toBeInTheDocument()
})
})
it('handles loading state', () => {
render(<UserProfile user={null} loading />)
expect(screen.getByTestId('loading')).toBeInTheDocument()
})
it('handles error state', () => {
render(<UserProfile user={null} error="Failed to load" />)
expect(screen.getByText('Failed to load')).toBeInTheDocument()
})
})import { describe, it, expect, beforeAll, afterAll } from 'vitest';
import { createTestClient } from './test-client';
describe('Users API', () => {
let client: TestClient;
beforeAll(() => {
client = createTestClient();
});
afterAll(async () => {
await client.cleanup();
});
it('creates a user', async () => {
const response = await client.post('/api/users', {
email: 'test@example.com',
name: 'Test User',
});
expect(response.status).toBe(201);
expect(response.data).toHaveProperty('id');
expect(response.data.email).toBe('test@example.com');
});
it('validates required fields', async () => {
const response = await client.post('/api/users', {});
expect(response.status).toBe(400);
expect(response.data).toHaveProperty('errors');
});
});describe('User Authentication Flow', () => {
beforeEach(() => {
cy.visit('/login');
});
it('allows user to login', () => {
cy.get('[data-testid="email-input"]').type('user@example.com');
cy.get('[data-testid="password-input"]').type('password123');
cy.get('[data-testid="login-button"]').click();
cy.url().should('include', '/dashboard');
cy.get('[data-testid="user-menu"]').should('be.visible');
});
it('shows error for invalid credentials', () => {
cy.get('[data-testid="email-input"]').type('invalid@example.com');
cy.get('[data-testid="password-input"]').type('wrong');
cy.get('[data-testid="login-button"]').click();
cy.get('[data-testid="error-message"]')
.should('be.visible')
.and('contain', 'Invalid credentials');
});
});# Generate unit tests
Generate unit tests for components/user-profile
# Generate API tests
Generate API tests for app/api/users
# Generate E2E tests
Generate E2E tests for user authentication flow
# Generate integration tests
Generate integration tests for user service