| name | role-qa-engineer |
| description | QA Engineer role in AID methodology. Use for test strategy, BDD scenarios, bug reporting, acceptance testing, flaky test prevention. |
QA Engineer Role
Core Responsibilities
- Design test strategies (TDD + BDD)
- Write BDD scenarios in Gherkin
- Identify edge cases and failures
- Validate acceptance criteria
- Ensure realistic test data
- Prevent flaky tests
- Investigate bugs systematically
Phase Focus
| Phase | Focus | Output |
|---|
| Discovery | Testability | Quality risks |
| PRD | Requirements review | Test plan, testable criteria |
| Tech Spec | Test architecture | Strategy, environment |
| Development | Test implementation | Test cases, bug reports |
| QA & Ship | Final validation | Results, sign-off |
BDD with Gherkin
Feature: User Authentication
Scenario: Successful login
Given I am on login page
When I enter valid credentials
Then I should see dashboard
Flaky Test Prevention
NO ARBITRARY TIMEOUTS.
await sleep(100);
await waitFor(() => result !== undefined);
Test Pollution
| Type | Fix |
|---|
| Shared state | Reset in beforeEach |
| File system | Use temp dirs |
| Database | Transaction rollback |
| Global mocks | Restore in afterEach |
Test Independence
Every test must pass alone AND with others in any order.
let user;
beforeAll(() => { user = createUser(); });
beforeEach(() => { user = createUser(); });
Realistic Test Data
| Category | Examples |
|---|
| Unicode | Jose, Japanese, emojis |
| Boundaries | Empty, 1 char, max |
| Special | O'Brien,
|
| Numbers | 0, -1, MAX_INT |
Bug Investigation
1. REPRODUCE - Exact steps, consistent?
2. ISOLATE - Minimal reproduction
3. DOCUMENT - Clear report with evidence
Bug Report Template
**Title**: [Action] + [Problem] + [Context]
**Severity**: Critical/Major/Minor
**Reproducibility**: Always/Sometimes/Once
### Steps to Reproduce
### Expected vs Actual
### Evidence
Anti-Patterns
| Anti-Pattern | Fix |
|---|
| Happy path only | Test failures |
| Fake test data | Realistic data |
| Arbitrary timeouts | Condition-based |
| Order-dependent | Fresh state |
| Over-mocking | Real dependencies |
| Technical Gherkin | Business language |
| Hardcoded credentials | Use env vars/factories |
| Weak assertions | Check specific values |
| Messy organization | Follow directory structure |
Test Code Organization
Directory Structure (Required)
tests/
├── unit/ # Fast, isolated tests
│ ├── services/
│ └── utils/
├── integration/ # Real dependencies
│ ├── api/
│ └── db/
├── e2e/ # End-to-end flows
├── fixtures/ # Test data factories
└── setup/ # Global configuration
File Naming Conventions
| Type | Pattern | Example |
|---|
| Unit | *.test.ts | user-service.test.ts |
| Integration | *.integration.test.ts | api.integration.test.ts |
| E2E | *.e2e.test.ts | login-flow.e2e.test.ts |
Test Naming
test('should_return_error_when_email_invalid', () => {});
Security in Test Code
IRON RULE: NO HARDCODED CREDENTIALS
const user = { email: 'admin@real.com', password: 'secret123' };
const user = {
email: process.env.TEST_EMAIL || 'test@example.com',
password: process.env.TEST_PASSWORD || 'test-only-pwd'
};
Security Checklist
See references/security-in-tests.md for patterns.
Test Independence Verification
Before Completion - MUST Verify:
-
Run in random order:
jest --runInBand --randomize
vitest --sequence.shuffle
pytest --randomly-seed=random
-
Run single test isolated:
jest --testNamePattern="specific test"
-
No shared state:
Run All Tests Requirement
IRON RULE: ALL TESTS MUST PASS
Before marking ANY task complete:
npm test
If Tests Fail:
- STOP - do not mark complete
- Check if your change caused it
- Fix before proceeding
Regression Checklist
Assertion Quality
Test Your Tests
Strong vs Weak Assertions
expect(result).toBeDefined();
expect(response).toBeTruthy();
expect(result).toEqual({ id: 1, name: 'User' });
expect(response.status).toBe(200);
expect(items).toHaveLength(3);
Assertion Checklist
Handoff Checklist
Test Coverage
Test Quality
Security
Organization