detectAsyncLeaks
- Type:
boolean - Default:
false - CLI:
--detectAsyncLeaks
Detect async resources that are still active after a test file finishes, such as timers that were not cleaned up.
This option uses Node.js async_hooks, so it may slow down tests. It is intended for debugging leaks and is not recommended for regular test runs.
Example
The following test leaks an interval:
When detectAsyncLeaks is enabled, Rstest fails the test file and reports the resource type and creation stack:
Clean up async resources before the test finishes to avoid the error: