{"id":19841276,"url":"https://github.com/codelenny/arbitrary-gh-webhook","last_synced_at":"2026-05-10T22:37:36.038Z","repository":{"id":90327174,"uuid":"116306743","full_name":"CodeLenny/arbitrary-gh-webhook","owner":"CodeLenny","description":"QuickCheck data for GitHub Webhooks","archived":false,"fork":false,"pushed_at":"2018-01-07T17:27:11.000Z","size":218,"stargazers_count":0,"open_issues_count":7,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-12T02:19:05.505Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/CodeLenny.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.adoc","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-01-04T20:55:42.000Z","updated_at":"2018-01-04T22:22:02.000Z","dependencies_parsed_at":null,"dependency_job_id":"fb38c72d-49c0-444e-88c3-440e92ff7bdc","html_url":"https://github.com/CodeLenny/arbitrary-gh-webhook","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CodeLenny%2Farbitrary-gh-webhook","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CodeLenny%2Farbitrary-gh-webhook/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CodeLenny%2Farbitrary-gh-webhook/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CodeLenny%2Farbitrary-gh-webhook/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CodeLenny","download_url":"https://codeload.github.com/CodeLenny/arbitrary-gh-webhook/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241210596,"owners_count":19927816,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-12T12:29:52.791Z","updated_at":"2026-05-10T22:37:36.008Z","avatar_url":"https://github.com/CodeLenny.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Arbitrary GitHub Webhooks\n\n[![arbitrary-gh-webhook on npm](https://img.shields.io/npm/v/arbitrary-gh-webhook.svg)](https://www.npmjs.com/package/arbitrary-gh-webhook)\n[![CI Results](https://img.shields.io/travis/CodeLenny/arbitrary-gh-webhook.svg)](https://travis-ci.org/CodeLenny/arbitrary-gh-webhook)\n[![Code Coverage](https://img.shields.io/codecov/c/github/codelenny/arbitrary-gh-webhook.svg)](https://codecov.io/gh/CodeLenny/arbitrary-gh-webhook)\n[![License details](https://img.shields.io/npm/l/arbitrary-gh-webhook.svg)](https://opensource.org/licenses/MIT)\n\nQuickCheck data for GitHub Webhooks.\n\n### Status\n\n`arbitrary-gh-webhook` is partially developed,\nwith each webhook being implemented in two stages.\n\n**Stage 1** webhooks are roughly implemented,\nbut may use generic \"random strings\" in some places instead of properly-formatted URLs,\nand might have some values that don't match (labels may belong to a different repository than the issue they are attached to).\n\n**Stage 2** will attempt to fix some of these issues by doing more post-processing of the generated data to make sure data makes sense.\n\n#### Status of Each Webhook\n\n- ArbitraryIssuesEvent  \n  Stage 1 added in [v0.1.0][]\n\n## Example Usage\n\n### Raw Webhook Testing\n\nWant semi-random [`IssuesEvent`][] webhooks\nto test an `issueHasLabels` function?\n\nLet's setup a testing environment.  You'll need [JSVerify][], a standard JavaScript [QuickCheck][] library.\n\nWe'll also be using [`ava-verify`][] in these examples to easily use [JSVerify][] with the [AVA][] test runner.\n\n```js\nconst jsc = require(\"jsverify\");\njsc.ava = require(\"ava-verify\");\n```\n\nThen grab `ArbitraryIssuesEvent` from this project, as well as the code you want to test (`issueHasLabels`):\n\n```js\nconst ArbitraryIssuesEvent = require(\"arbitrary-gh-webhook/hooks/ArbitraryIssuesEvent\");\nconst issueHasLabels = require(\"../issueHasLabels\");\n```\n\nNow write your tests!  Thanks to [JSVerify][] and [`ava-verify`][], they will run multiple times\n(by default, 100 iterations) with different test data.\n\n```js\njsc.ava({\n    suite: \"issueHasLabels returns a boolean\",\n  }, [\n    ArbitraryIssuesEvent.build(),\n  ], (t, issueData) =\u003e {\n    t.is(typeof issueHasLabels(issueData), \"boolean\");\n  }\n);\n```\n\nAdditionally, `arbitrary-gh-webhook` was built using [ConfigurableArbitrary][], which allows you to tweak\nhow webhooks are built.\n\nFor instance, you might want to test specifically what happens if the webhook returns an issue with a specific number of labels.\n\nYou can override specific parts of the webhook, while the rest is still randomly created:\n\n```js\nconst jsc = require(\"jsverify\");\njsc.ava = require(\"ava-verify\");\nconst arrayRange = require(\"jsverify-array-range\");\n\nconst ArbitraryIssuesEvent = require(\"arbitrary-gh-webhook/hooks/ArbitraryIssuesEvent\");\nconst WebhookIssue = require(\"arbitrary-gh-webhook/data/WebhookIssue\");\nconst WebhookLabelList = require(\"arbitrary-gh-webhook/data/WebhookLabelList\");\n\nconst issueHasLabels = require(\"../issueHasLabels\");\n\n\njsc.ava({\n    suite: \"issueHasLabels returns 'false' if Issue has 0 labels\",\n  }, [\n    ArbitraryIssuesEvent.build({\n      issue: WebhookIssue.build({\n        labels: WebhookLabelList.build({ max: 0 }),\n      }),\n    }),\n  ], (t, issueData) =\u003e {\n    t.is(issueHasLabels(issueData), false);\n  }\n);\n\njsc.ava({\n    suite: \"issueHasLabels returns 'true' if Issue has 1+ labels\",\n  }, [\n    ArbitraryIssuesEvent.build({\n      issue: WebhookIssue.build({\n        labels: WebhookLabelList.build({ min: 1 }),\n      }),\n    }),\n  ], (t, issueData) =\u003e {\n    t.is(issueHasLabels(issueData), true);\n  }\n);\n```\n\n### Usage with [SuperAgent][]\n\nRequests include a built-in [SuperAgent][] module, so you can easily send requests to a webserver.\n\nLet's say you've got a standard [Express][] server that should handle the [`IssuesEvent`][].\n\n```js\nconst jsc = require(\"jsverify\");\njsc.ava = require(\"ava-verify\");\nconst ArbitraryIssuesEvent = require(\"arbitrary-gh-webhook/hooks/ArbitraryIssuesEvent\");\nconst request = require(\"supertest\");\n\nconst Server = require(\"../index.js\");\n\njsc.ava({\n    suite: \"server stores new issues\",\n  }, [\n    ArbitraryIssuesEvent.build(),\n  ], async (t, webhook) =\u003e {\n    t.plan(2);\n    const server = new Server();\n    await request(server.app)\n      .post(\"/hook/gh/issues\")\n      .use(webhook.superagent)\n      .then(res =\u003e t.is(res.status, 200));\n    t.true(server.hasIssue(webhook.body.issue.id));\n  }\n);\n```\n\n[QuickCheck]: https://en.wikipedia.org/wiki/QuickCheck\n[JSVerify]: https://github.com/jsverify/jsverify\n[AVA]: https://github.com/avajs/ava\n[ConfigurableArbitrary]: https://github.com/rweda/configurable-arbitrary\n[`ava-verify`]: https://www.npmjs.com/package/ava-verify\n[SuperAgent]: https://github.com/visionmedia/superagent\n[Express]: https://expressjs.com/\n[`IssuesEvent`]: https://developer.github.com/v3/activity/events/types/#issuesevent\n\n[v0.1.0]: https://github.com/CodeLenny/arbitrary-gh-webhook/tree/v0.1.0\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodelenny%2Farbitrary-gh-webhook","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodelenny%2Farbitrary-gh-webhook","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodelenny%2Farbitrary-gh-webhook/lists"}