Usage
Create a webhook URL
UsegetWebhookUrl to generate a unique webhook.site URL for your test.
Configure your application to send webhooks to this URL.
Custom assertion
Use thetoHaveReceivedWebhook assertion to verify that a webhook was received.
Pass any webhook.site URL to expect() — either one generated with getWebhookUrl
or an existing URL — and specify content to match against the body.
Querying webhooks
UsequeryWebhookRequests to fetch matching webhook requests directly. This
is useful when you need to inspect the payload for further assertions.
WebhookRequest with the following
properties:
| Property | Type | Description |
|---|---|---|
content | string | Raw request body (parse with JSON.parse for JSON payloads) |
method | string | HTTP method (e.g. POST) |
headers | Record<string, string[]> | Request headers |
url | string | Full request URL |
created_at | string | Timestamp of when the request was received |
Assertion options
| Option | Type | Default | Description |
|---|---|---|---|
content | string | string[] | Required | One or more terms to match against the webhook body. Multiple terms are AND’d together. |
timeout | number | 300000 | Maximum time in milliseconds to wait for the webhook (default: 5 minutes) |