Test Configuration
// Jest Configuration
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
coverageThreshold: {
global: {
branches: 80,
functions: 80,
lines: 80,
statements: 80
}
},
collectCoverageFrom: [
'src/**/*.{js,ts}',
'!src/**/*.d.ts'
]
}
Integration Tests
describe('API Integration Tests', () => {
beforeAll(async () => {
await startTestServer();
});
afterAll(async () => {
await stopTestServer();
});
test('should create new user', async () => {
const response = await request(app)
.post('/api/users')
.send({
name: 'Test User',
email: 'test@example.com'
});
expect(response.status).toBe(201);
expect(response.body).toHaveProperty('id');
});
});