Create webhook regression tests

Guides / Tests

A regression test in HookWatcher is a real webhook plus what your handler should answer. It's built from captured traffic, so it covers the payloads your provider actually sends rather than the ones you remembered to write fixtures for.

Create one

  • From an event: Save as Test on any event, or hwcli test create payment-success --from evt_93df18ab --expect-status 200.
  • From a Debug Session: the final successful attempt becomes the test, expecting the response it got. hwcli test create invoice-fixed --from-debug-session <session-id>.
  • From YAML, kept in your repository with your code: hwcli test apply tests/webhooks/*.yaml.
name: payment-success
suite: payments
event:
  source: evt_93df18ab
target:
  path: /webhooks/payment
signature: resign
modify:
  set:
    data.object.amount: 5000
expect:
  status: 200
  latency:
    max: 500
  response:
    json:
      success: true
  assertions:
    - path: order.status
      op: equals
      value: paid

Expectations

  • status: one code or a list.
  • latency.max: the slowest acceptable response, in milliseconds.
  • response.json: a subset match. Every field you list must be present with that value, and other fields are ignored.
  • response.headers and response.contains check headers and text.
  • assertions: JSON paths with equals, not_equals, exists, absent, contains, matches, gt, gte, lt, lte or type.

Tests outlive retention

A test keeps its own copy of the request, so it still runs after the original event expires under your plan's retention. Credential headers in that copy are stored encrypted. You can have 5 tests on Free and 250 on Pro.

Run them locally with hwcli test run, from the Tests view in the dashboard, or in CI.

Create an endpoint and capture your first webhook. No signup needed.

Start Free