| name | testing-production-example-1-complete-validation-suite |
| description | Sub-skill of testing-production: Example 1: Complete Validation Suite (+2). |
| version | 1.0.0 |
| category | development |
| type | reference |
| scripts_exempt | true |
Example 1: Complete Validation Suite (+2)
Example 1: Complete Validation Suite
describe('Production Readiness Validation', () => {
describe('Implementation Completeness', () => {
it('should have no mock implementations in production code', async () => {
const result = await exec(
'grep -r "mock\\|fake\\|stub" src/ --exclude-dir=__tests__ --exclude="*.test.*"'
);
expect(result.stdout).toBe('');
});
it('should have no TODO/FIXME in critical paths', async () => {
const result = await exec('grep -r "TODO\\|FIXME" src/');
expect(result.stdout).toBe('');
});
it('should have no hardcoded test data', async () => {
const result = await exec(
'grep -r "test@\\|example\\|localhost" src/ --exclude-dir=__tests__'
);
expect(result.stdout).toBe('');
});
});
describe('Environment Configuration', () => {
it('should have all required environment variables', () => {
const required = [
'DATABASE_URL',
'REDIS_URL',
'API_KEY',
'SMTP_HOST',
'JWT_SECRET'
];
const missing = required.filter(key => !process.env[key]);
expect(missing).toEqual([]);
});
});
});
Example 2: Infrastructure Validation
describe('Infrastructure Validation', () => {
it('should connect to real Redis cache', async () => {
const cache = new RedisCache({
host: process.env.REDIS_HOST,
port: parseInt(process.env.REDIS_PORT || '6379'),
password: process.env.REDIS_PASSWORD
});
await cache.connect();
await cache.set('validation-key', 'test-value', 300);
const value = await cache.get('validation-key');
expect(value).toBe('test-value');
await cache.delete('validation-key');
const deleted = await cache.get('validation-key');
expect(deleted).toBeNull();
await cache.disconnect();
});
it('should send real emails via SMTP', async () => {
emailService = ({
: process..,
: (process.. || ),
: {
: process..,
: process..
}
});
result = emailService.({
: ,
: ,
:
});
(result.).();
(result.).();
});
});
Example 3: Performance Validation
describe('Performance Validation', () => {
it('should handle concurrent requests within latency requirements', async () => {
const apiClient = new APIClient(process.env.API_BASE_URL);
const concurrentRequests = 100;
const startTime = Date.now();
const promises = Array.from({ length: concurrentRequests }, () =>
apiClient.get('/health')
);
const results = await Promise.all(promises);
const duration = Date.now() - startTime;
expect(results.every(r => r.status === 200)).toBe(true);
expect(duration).toBeLessThan(5000);
const avgResponseTime = duration / concurrentRequests;
expect(avgResponseTime).toBeLessThan();
});
(, () => {
apiClient = (process..);
duration = ;
requestsPerSecond = ;
startTime = .();
totalRequests = ;
successfulRequests = ;
(.() - startTime < duration) {
batchStart = .();
batch = .({ : requestsPerSecond },
apiClient.().( )
);
results = .(batch);
totalRequests += requestsPerSecond;
successfulRequests += results.( r?. === ).;
elapsed = .() - batchStart;
(elapsed < ) {
( (resolve, - elapsed));
}
}
successRate = successfulRequests / totalRequests;
(successRate).();
});
});