AI Skill Report Card

Writing Automated Tests

A85·Feb 4, 2026
JavaScript
// Example: Testing a user validation function const { validateUser } = require('./user'); describe('validateUser', () => { test('accepts valid user data', () => { const validUser = { name: 'John', email: 'john@example.com', age: 25 }; expect(validateUser(validUser)).toBe(true); }); test('rejects user with invalid email', () => { const invalidUser = { name: 'John', email: 'invalid-email', age: 25 }; expect(validateUser(invalidUser)).toBe(false); }); test('rejects user under minimum age', () => { const underageUser = { name: 'John', email: 'john@example.com', age: 12 }; expect(validateUser(underageUser)).toBe(false); }); });
Recommendation
Add concrete examples of mocking external dependencies (database, API calls) with specific input/output pairs

Progress:

  • Set up testing framework (Jest, Vitest, pytest, etc.)
  • Configure static analysis tools (TypeScript, ESLint, mypy)
  • Write unit tests for core business logic
  • Add integration tests for critical workflows
  • Set up CI pipeline to run tests automatically
  • Add test coverage reporting
  • Write end-to-end tests for user journeys

Test Types Priority:

  1. Unit tests - Individual functions and methods
  2. Integration tests - Components working together
  3. End-to-end tests - Full user workflows
Recommendation
Include a template or checklist for test case scenarios (happy path, edge cases, error conditions)

Example 1: API Endpoint Testing Input: Express route that creates a user

JavaScript
app.post('/users', async (req, res) => { const user = await User.create(req.body); res.json(user); });

Output:

JavaScript
describe('POST /users', () => { test('creates user with valid data', async () => { const userData = { name: 'Alice', email: 'alice@test.com' }; const response = await request(app) .post('/users') .send(userData) .expect(200); expect(response.body.name).toBe('Alice'); expect(response.body.email).toBe('alice@test.com'); }); test('returns 400 for invalid data', async () => { await request(app) .post('/users') .send({ name: '' }) .expect(400); }); });

Example 2: React Component Testing Input: Button component with click handler Output:

JavaScript
import { render, fireEvent, screen } from '@testing-library/react'; import Button from './Button'; test('calls onClick when clicked', () => { const handleClick = jest.fn(); render(<Button onClick={handleClick}>Click me</Button>); fireEvent.click(screen.getByText('Click me')); expect(handleClick).toHaveBeenCalledTimes(1); });
Recommendation
Show specific CI/CD pipeline configuration examples (GitHub Actions, Jenkins) rather than just mentioning setup

Focus on Confidence, Not Coverage

  • Test business logic thoroughly
  • Don't test framework code or trivial getters/setters
  • Aim for 80%+ coverage on critical paths

Test Structure (AAA Pattern)

  • Arrange: Set up test data and conditions
  • Act: Execute the code under test
  • Assert: Verify the expected outcome

Naming Convention

  • Describe what the test does: should_return_error_when_email_is_invalid
  • Use descriptive test names that serve as documentation

Mock External Dependencies

  • Database calls, API requests, file system operations
  • Keep tests fast and isolated
  • Use dependency injection for easier mocking

Testing Implementation Details

  • Don't test private methods directly
  • Test behavior, not internal structure
  • Avoid brittle tests that break on refactoring

Over-Mocking

  • Don't mock everything - test real integration where valuable
  • Mock at the boundary of your system
  • Avoid mocking the system under test

Flaky Tests

  • Avoid time-dependent tests without proper mocking
  • Don't rely on external services in unit tests
  • Use deterministic test data

Writing Tests After Code

  • Write tests during or before implementation
  • Tests written after are often less thorough
  • Consider test-driven development (TDD) for complex logic
0
Grade AAI Skill Framework
Scorecard
Criteria Breakdown
Quick Start
11/15
Workflow
11/15
Examples
15/20
Completeness
15/20
Format
11/15
Conciseness
11/15