(
collection: any,
testFn: (tracker: { stats: IndexUsageStats }) => void | Promise<void>,
)
| 191 | |
| 192 | // Helper to run a test with index usage tracking (automatically handles setup/cleanup) |
| 193 | export function withIndexTracking( |
| 194 | collection: any, |
| 195 | testFn: (tracker: { stats: IndexUsageStats }) => void | Promise<void>, |
| 196 | ): void | Promise<void> { |
| 197 | const tracker = createIndexUsageTracker(collection) |
| 198 | |
| 199 | try { |
| 200 | const result = testFn(tracker) |
| 201 | if (result instanceof Promise) { |
| 202 | return result.finally(() => tracker.restore()) |
| 203 | } |
| 204 | tracker.restore() |
| 205 | } catch (error) { |
| 206 | tracker.restore() |
| 207 | throw error |
| 208 | } |
| 209 | } |
| 210 | |
| 211 | type MockSyncCollectionConfig<T extends object = Record<string, unknown>> = { |
| 212 | id: string |
no test coverage detected