
What Auto Cleanup Does
Every API test run creates real records in your test environment: users, orders, sessions, files. Left behind, they break later runs:order_id, get cleaned up; plain values, like a total_amount, don’t.
The Cleanup Tab
Open Test Runs → a run → Cleanup to see what was deleted (or attempted) after that run. Captured resources show as cards in two sections:
Each card shows:
A progress bar at the top summarizes how many captured resources have been cleaned up.
When Cleanup Runs
Once all endpoint and integration tests finish, TestSprite issues the DELETE calls. Cleanup usually takes 5–60 seconds depending on resource count. The dashboard stays usable meanwhile, but the run isn’t fully done until cleanup finishes.When Cleanup Fails
To retry, rerun the failing cleanup test from its detail page, or Re-run all. Every rerun runs Auto Cleanup again at the end.
Manual Cleanup
If a resource couldn’t be auto-cleaned (no matching DELETE endpoint was discovered), it appears under Might be orphaned with its ID and source endpoint. You can:- Add a DELETE endpoint to discovery: re-run API Discovery once your DELETE endpoints are reachable
- Delete it yourself with your own backend tooling
Edge Cases & Troubleshooting
Cleanup left some records behind
Cleanup left some records behind
Most likely causes:
- No DELETE endpoint discovered: shown under “Might be orphaned”. Add the endpoint manually on the configuration step (or in a new project) so cleanup has a verb to invoke.
- DELETE endpoint failed with 4xx: the cleanup test shows Failed with the response body. Often an auth or permission issue with the test account.
- Deeply nested children (4+ levels) can need a hint. Refine in chat: “DELETE /comments must run before DELETE /posts must run before DELETE /users”.
Cleanup is deleting records I want to keep
Cleanup is deleting records I want to keep
Refine: “Don’t auto-clean up the seed-data user
system@testsprite.com”. TestSprite will skip cleanup for resources matching that filter.Cleanup runs are slow (>5 minutes)
Cleanup runs are slow (>5 minutes)
- Many resources: 1000+ created records means 1000+ DELETE calls. Prune the plan to create less, or accept the cost.
- Slow DELETE endpoint: if each DELETE takes 5+ seconds, investigate on your API side.
- Many retries: check the Cleanup tab for the failure pattern.
Cleanup didn't run at all
Cleanup didn't run at all
- The run must be finished (tests Passed or Failed, none Running). Cleanup starts after the run completes.
- At least one cleanup-relevant record must exist. If your tests don’t produce record IDs, there’s nothing to clean up.
My cleanup DELETEs are getting rate-limited
My cleanup DELETEs are getting rate-limited
Cleanup issues DELETEs in parallel for resources of the same type. If your API rate-limits DELETE, refine: “Issue cleanup DELETEs serially, not in parallel”.
Where to Go Next
Dynamic Variables
See which test deleted each captured value, next to where it came from
Dependency Chains
How run order is determined
Auto-Auth
Keeps auth alive across long-running cleanups