Skip to main content

@idpass/data-collect-core / StorageFaultInjector

Class: StorageFaultInjector<T>

Defined in: testing/StorageFaultInjector.ts:44

Wraps any object with a Proxy that can inject faults based on configurable rules.

Useful for testing error handling and retry logic in storage adapters, services, and other components that depend on external resources.

Type Parameters​

T​

T extends object

The type of the target object to wrap

Constructors​

Constructor​

new StorageFaultInjector<T>(target): StorageFaultInjector<T>

Defined in: testing/StorageFaultInjector.ts:48

Parameters​

target​

T

Returns​

StorageFaultInjector<T>

Methods​

addRule()​

addRule(rule): void

Defined in: testing/StorageFaultInjector.ts:53

Add a fault injection rule.

Parameters​

rule​

FaultRule

Returns​

void


reset()​

reset(): void

Defined in: testing/StorageFaultInjector.ts:60

Reset all rules and call counts.

Returns​

void


getCallCount()​

getCallCount(operation): number

Defined in: testing/StorageFaultInjector.ts:68

Returns the number of times a specific operation has been called.

Parameters​

operation​

string

Returns​

number


getProxy()​

getProxy(): T

Defined in: testing/StorageFaultInjector.ts:76

Returns a Proxy around the target that intercepts method calls and applies fault rules.

Returns​

T