Dev.to
7/24/2026

The original headline is "How a Single beforeEach Killed Our CI for 36 Hours"
Original: How a Single beforeEach Killed Our CI for 36 Hours
Short summary
A single beforeEach hook that truncated all 76 tables before each of 1,140 tests caused 86,640 TRUNCATE CASCADE operations, hanging CI for 36 hours. The fix replaced per-test truncation with beforeAll schema sync plus unique test data using timestamps/random suffixes, reducing suite runtime from 6+ hours to ~3 minutes. The article also covers transaction-rollback isolation as an alternative and the importance of setting explicit CI timeouts.
- •beforeEach TRUNCATE on 76 tables × 1,140 tests = 86,640 operations caused CI timeout
- •Fix: beforeAll sync + unique test data (timestamps/UUIDs) instead of per-test cleanup
- •Suite dropped from 6+ hours to ~3 minutes; set explicit CI step timeouts
Generated with AI, which can make mistakes.
Is this a good recommendation for you?



