Function: setCacheInstance()
setCacheInstance<
S,K>(container,key,value):void
Defined in: src/utils/set-cache-instance.ts:20
Overrides the cached value of key in container until the next reset(), without touching the registration. Resolutions through this container (and its forks) return value.
For tests, prefer an isolated fork with a replacement, which cannot leak: app.fork({ isolated: true }).addInstance('db', fakeDb, { replace: true }).
Type Parameters
S
S extends object
K
K extends string | number | symbol
Parameters
container
DIContainer<S> | SealedDIContainer<S>
key
K
value
ServiceType<S, K>
Returns
void
Example
ts
setCacheInstance(app, 'clock', fixedClock);
// ... test
app.reset();