Test organization best practices: 1) Keep tests close to source files, 2) Use consistent naming conventions (.test.js, .spec.js), 3) Group related tests in describe blocks, 4) Organize by feature or component, 5) Maintain clear file structure.
Assertion best practices: 1) Use specific assertions, 2) Keep assertions focused, 3) Use meaningful error messages, 4) Avoid multiple assertions when possible, 5) Test one concept per test case.
AAA pattern involves: 1) Arrange - setup test data and conditions, 2) Act - perform the action being tested, 3) Assert - verify the expected outcome. Important for: test clarity, maintainability, and proper organization of test logic.
Complex component patterns: 1) Break down into smaller test cases, 2) Test component integration, 3) Verify state management, 4) Test edge cases, 5) Maintain test isolation.
Utility testing practices: 1) Test pure functions thoroughly, 2) Cover edge cases, 3) Test input validation, 4) Verify error handling, 5) Maintain function independence.
Microservice testing patterns: 1) Test service boundaries, 2) Verify service communication, 3) Test service isolation, 4) Check service resilience, 5) Test service scaling.
Hook guidelines: 1) Use beforeAll for one-time setup, 2) Use beforeEach for per-test setup, 3) Clean up resources in afterEach/afterAll, 4) Keep hooks focused and minimal, 5) Avoid complex logic in hooks.
Error testing practices: 1) Test expected error conditions, 2) Verify error messages and types, 3) Test error handling behavior, 4) Use proper error assertions, 5) Consider edge cases and invalid inputs.
Maintenance practices: 1) Regular test cleanup, 2) Update tests with code changes, 3) Remove obsolete tests, 4) Maintain test documentation, 5) Refactor tests when needed. Keep tests current and valuable.
Async test structure: 1) Use async/await consistently, 2) Handle promises properly, 3) Set appropriate timeouts, 4) Test both success and failure cases, 5) Verify async state changes.
Coverage management: 1) Set realistic coverage goals, 2) Focus on critical paths, 3) Don't chase 100% blindly, 4) Monitor coverage trends, 5) Use coverage reports effectively.
State management patterns: 1) Test state transitions, 2) Verify state updates, 3) Test state synchronization, 4) Check state persistence, 5) Test state cleanup.
Large suite management: 1) Organize tests effectively, 2) Implement test categorization, 3) Maintain test independence, 4) Optimize test execution, 5) Monitor test health.
Test data management: 1) Use fixtures for consistent data, 2) Implement factory functions, 3) Clean up test data after use, 4) Keep test data minimal and focused, 5) Avoid sharing mutable test data between tests.
Mock best practices: 1) Only mock what's necessary, 2) Keep mocks simple, 3) Clean up mocks after tests, 4) Use meaningful mock implementations, 5) Avoid mocking everything. Mocks should be minimal and focused.
Performance optimization: 1) Minimize test setup, 2) Use efficient assertions, 3) Optimize mock usage, 4) Implement proper test isolation, 5) Use test parallelization effectively.
Advanced interaction testing: 1) Test complex user flows, 2) Verify component communication, 3) Test state propagation, 4) Check event handling, 5) Test integration points.
Async workflow testing: 1) Test workflow steps, 2) Verify state transitions, 3) Test error recovery, 4) Check workflow completion, 5) Test concurrent workflows.
Data pipeline practices: 1) Test data transformations, 2) Verify data integrity, 3) Test pipeline stages, 4) Check error handling, 5) Test pipeline recovery.
System integration structure: 1) Define integration boundaries, 2) Test system interactions, 3) Verify end-to-end flows, 4) Test system resilience, 5) Check system recovery.
Key principles include: 1) Test isolation - each test should be independent, 2) Clear test descriptions, 3) Single assertion per test when possible, 4) Proper setup and cleanup, 5) Following the Arrange-Act-Assert pattern, 6) Testing behavior not implementation, 7) Maintaining test readability.
Good test descriptions: 1) Clearly state what's being tested, 2) Describe expected behavior, 3) Use consistent terminology, 4) Follow 'it should...' pattern, 5) Are specific and unambiguous. Helps with test documentation and maintenance.
Integration test organization: 1) Group related scenarios, 2) Test component interactions, 3) Verify system integration, 4) Maintain clear test boundaries, 5) Focus on integration points.
Hook testing patterns: 1) Test hook behavior, 2) Verify state changes, 3) Test effect cleanup, 4) Check dependency updates, 5) Test error cases. Use @testing-library/react-hooks.
Test double management: 1) Use appropriate double types, 2) Maintain double fidelity, 3) Clean up doubles after use, 4) Document double behavior, 5) Verify double interactions.
Distributed system practices: 1) Test network partitions, 2) Verify data consistency, 3) Test system recovery, 4) Check system coordination, 5) Test scaling behavior.
Security testing patterns: 1) Test authentication flows, 2) Verify authorization rules, 3) Test data protection, 4) Check security boundaries, 5) Test security policies.