IsolationStrategy.SNAPSHOT tracks entities created during your suite and removes them when the suite finishes. This is not a full state snapshot - it only records which entities were created so they can be cleaned up. Existing entities are not captured or restored.
When to Use
- Tests that create entities and need them cleaned up automatically
- Tests that attach components to newly created entities
- Any test where you want created entities removed after the suite
How It Works
1
Before Suite
HRTK creates a
TestEntityTracker that begins recording entity creations in the ECS store.2
Test Execution
Your tests run normally, creating entities and mutating ECS state as needed. The tracker records every entity created during the suite.
3
After Suite
HRTK calls
tracker.cleanup() to remove all entities that were created during the suite. Modifications to pre-existing entities are NOT reverted.Usage
What Is Tracked and What Is Not
Performance
Entity tracking has minimal overhead - it simply records references to created entities during the suite and removes them at the end. The cleanup cost scales with the number of entities created, not the total size of the ECS store. This cost is paid once per suite (not per test).Complete Example
Next Steps
- Isolation: NONE - no protection, fastest
- Isolation: DEDICATED_WORLD - full world isolation
- Isolation Overview - strategy comparison