TestKit
Defined in: src/testkit/TestKit.ts:24
Convenience fassade to create an ActorSystem pre-wired for deterministic testing: NoopLogger by default and a TestProbe factory handy.
Typical usage:
const tk = TestKit.create(‘my-spec’); const probe = tk.createTestProbe(); const ref = tk.system.actorOf(Props.create(() => new Worker(probe)), ‘worker’); ref.tell(‘go’); await probe.expectMsg(‘done’); await tk.shutdown();
Properties
Section titled “Properties”system
Section titled “system”
readonlysystem:ActorSystem
Defined in: src/testkit/TestKit.ts:25
Methods
Section titled “Methods”createTestProbe()
Section titled “createTestProbe()”createTestProbe(
opts?):TestProbe
Defined in: src/testkit/TestKit.ts:42
Create a TestProbe scoped to this kit’s system.
Parameters
Section titled “Parameters”TestProbeOptions = {}
Returns
Section titled “Returns”shutdown()
Section titled “shutdown()”shutdown():
Promise<void>
Defined in: src/testkit/TestKit.ts:58
Tear the system down at the end of a test.
Returns
Section titled “Returns”Promise<void>
within()
Section titled “within()”within<
T>(durationMs,fn):Promise<T>
Defined in: src/testkit/TestKit.ts:47
Run fn with a soft deadline; throws if it takes longer than durationMs.
Type Parameters
Section titled “Type Parameters”T
Parameters
Section titled “Parameters”durationMs
Section titled “durationMs”number
() => Promise<T>
Returns
Section titled “Returns”Promise<T>
create()
Section titled “create()”
staticcreate(name?,options?):TestKit
Defined in: src/testkit/TestKit.ts:31
Parameters
Section titled “Parameters”string = 'test-kit'
options?
Section titled “options?”TestKitOptions = {}
Returns
Section titled “Returns”TestKit
withManualScheduler()
Section titled “withManualScheduler()”
staticwithManualScheduler(name?,options?):object
Defined in: src/testkit/TestKit.ts:66
Build a TestKit that uses a ManualScheduler so that timers fire
deterministically via scheduler.advance(ms).
Parameters
Section titled “Parameters”string = 'test-kit-manual'
options?
Section titled “options?”Omit<TestKitOptions, "scheduler"> = {}
Returns
Section titled “Returns”object
kit:
TestKit
scheduler
Section titled “scheduler”scheduler:
ManualScheduler