Skip to content

@xtandard/webhooks/testing

Testing utilities — @xtandard/webhooks/testing.

Everything a host app (or this package’s own suite) needs to test its webhook wiring without the network or timers:

  • createTestWebhooks: an in-memory core + a not-started dispatcher, driven manually via dispatcher.tick() / drainDeliveries.
  • createTestReceiver: a real local HTTP server that records (and, given the secret, verifies) every delivery it receives — including programmable failures to exercise the retry path.
import { … } from "@xtandard/webhooks/testing";
Name Summary
createTestReceiver Start a real local HTTP server that plays the receiving side of a webhook. Works under Bun and Node.
createTestWebhooks An in-memory core + dispatcher for tests. The dispatcher is not started (no timers) and defaults to an immediate three-attempt retry schedule so failure paths drain in a few ticks.
drainDeliveries Tick the dispatcher until a pass makes no attempts (or maxTicks is hit). Pair with an all-immediate retry schedule (createTestWebhooks’s default) so failed deliveries are due again on the very next tick.
Name Summary
TestReceiver A running test receiver.
TestReceiverOptions Options for createTestReceiver.
TestWebhooks Result of createTestWebhooks.
TestWebhooksOptions Options for createTestWebhooks.