Instead of setTimeout (flaky) or sleep (slow), use barriers to pause execution at exact interleave points. The test controls when each concurrent operation proceeds, making race condition tests deterministic and reproducible on every run.
When to use: Testing concurrent operations, flush conflicts, parallel mutations, race windows between read and write, lock contention scenarios, any code where timing affects correctness.
When not to use: Sequential-only code, simple unit tests, UI components, read-only operations, code with no concurrency concerns.
Tests déterministes de condition de concurrence utilisant des barrières et des promesses différées. Remplace les tests de synchronisation instables basés sur setTimeout par un contrôle d'entrelacement reproductible. Source : apankov1/quality-engineering.