GitHub + Jest

Validate push and pull request webhook events in a Jest integration suite.

import { WebhooksCC, matchHeader, matchBodyPath, matchAll } from "@webhooks-cc/sdk";

const client = new WebhooksCC({ apiKey: process.env.WHK_API_KEY! });

test("receives GitHub push webhook", async () => {
  const endpoint = await client.endpoints.create({ name: "github-jest" });
  try {
    await triggerGitHubPush({ webhookUrl: endpoint.url! });

    const req = await client.requests.waitFor(endpoint.slug, {
      timeout: "20s",
      match: matchAll(
        matchHeader("x-github-event", "push"),
        matchBodyPath("ref", "refs/heads/main")
      ),
    });

    expect(req.headers["x-github-event"]).toBe("push");
  } finally {
    await client.endpoints.delete(endpoint.slug);
  }
});

Next: Playwright E2E