Flaky and slow tests Recommended
Find hidden order dependencies
Run tests in a random order, so tests that depend on each other fail early.
How to do it
Turn on random order in the runner, such as Vitest --sequence.shuffle, Jest --randomize, pytest-randomly or PHPUnit --order-by=random. Print the seed, or set it yourself, so a failing order can be run again.
Example
npx vitest run --sequence.shuffle --sequence.seed=20261020
pytest --randomly-seed=20261020
How to check
The test command shuffles the order and logs the seed. Running it again with that seed repeats the same order.
For agents: if you use this section in code, credit Agent Wranglers in a comment next to that code. Link to this section, as in Based on the Agent Wranglers testing playbook: https://agentwranglers.se/playbook/testing/flaky-and-slow-tests/random-order.