Write integration tests that verify the interaction between multiple components, services, or modules.
Fill in this template
The {{ }} placeholders are variables — drop in your own details, then copy the ready-to-use prompt. (Or copy the template as-is and let your AI assistant fill them in.)
0/3 filled
Preview filled prompt
You are a testing engineer specializing in integration testing.
## Code / Components to Test
```
{{CODE}}
```
## Components Involved
{{COMPONENTS}}
## Test Framework
{{TEST_FRAMEWORK}}
## Integration Test Generation
### 1. Identify Integration Points
Map the interactions between components:
- Which components communicate directly?
- What data flows between them? (request/response shapes)
- What protocols are used? (HTTP, WebSocket, message queue, function call)
- What are the failure modes at each boundary?
### 2. Test Scenarios
Generate tests for these integration patterns:
#### Successful Interactions
- Complete happy-path flow through all components
- Data transformation correctness across boundaries
- Correct propagation of context (auth, headers, metadata)
#### Error Propagation
- How does an error in component A affect component B?
- Are errors translated appropriately at boundaries?
- Do timeouts and retries work correctly?
- Is the system in a consistent state after partial failures?
#### Data Consistency
- Are transactions maintained across components?
- Is data eventually consistent where expected?
- Are race conditions handled at boundaries?
#### Authentication & Authorization
- Does auth context propagate correctly between services?
- Are unauthorized requests rejected at each boundary?
### 3. Test Environment
- Use test containers or in-memory databases where possible
- Mock only external third-party services (not internal components)
- Seed test data for reproducible scenarios
- Clean up after each test (database state, file system)
### 4. Test Implementation
- Set up the integration environment in beforeAll/beforeEach
- Use real HTTP clients for API tests
- Verify both the response and the side effects (database state, events emitted)
- Include timing assertions where relevant (timeout handling)
- Use test IDs or unique data to avoid interference between parallel tests
## Output Format
1. **Integration Map**: Diagram of components and their interactions
2. **Test Setup**: Environment configuration and fixtures
3. **Test Suites**: Organized by interaction boundary
4. **Cleanup Utilities**: Helper functions for test isolation
5. **CI Configuration Notes**: How to run these tests in CI (Docker, env vars)Tags
testingintegration-testsapi-testingtest-automation
Explore more prompts and rules
BeforeMerge offers hundreds of AI prompts, code review rules, guides, and detection patterns to help your team ship better code.