question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support loading smee payloads as test fixtures

See original GitHub issue

Suggested by @johnkpaul & @Gautam, it’d be really awesome if the payloads copied from smee.io could be easily loaded as test fixtures.

Describe the solution you’d like

Currently the payload is a JSON object with all the request headers, and then a body property that includes the actual payload.

Example smee payload
{
   "connection" : "close",
   "x-forwarded-port" : "443",
   "content-type" : "application/json",
   "timestamp" : 1529466287817,
   "content-length" : "9915",
   "x-github-delivery" : "47242110-743c-11e8-9817-a7977c0f2c44",
   "x-forwarded-proto" : "https",
   "user-agent" : "GitHub-Hookshot/8ec4fc1",
   "x-request-start" : "1529466287813",
   "x-request-id" : "5e8e11f1-2961-4a3d-99c8-208b062e3667",
   "x-forwarded-for" : "192.30.252.36",
   "host" : "smee.io",
   "via" : "1.1 vegur",
   "accept" : "*/*",
   "x-hub-signature" : "sha1=cb8a46159a67ec38f6b1580aa614deda77d3df11",
   "connect-time" : "1",
   "total-route-time" : "0",
   "x-github-event" : "issue_comment",
   "body" : {
      "action" : "created",
      "comment" : {
         "body" : "@bkeepers set a reminder for **Jun 20th 2018**",
         "user" : {
            "id" : 38381849,
            "starred_url" : "https://api.github.com/users/bkeepers-dev%5Bbot%5D/starred{/owner}{/repo}",
            "site_admin" : false,
            "html_url" : "https://github.com/apps/bkeepers-dev",
            "events_url" : "https://api.github.com/users/bkeepers-dev%5Bbot%5D/events{/privacy}",
            "node_id" : "MDM6Qm90MzgzODE4NDk=",
            "repos_url" : "https://api.github.com/users/bkeepers-dev%5Bbot%5D/repos",
            "login" : "bkeepers-dev[bot]",
            "following_url" : "https://api.github.com/users/bkeepers-dev%5Bbot%5D/following{/other_user}",
            "type" : "Bot",
            "subscriptions_url" : "https://api.github.com/users/bkeepers-dev%5Bbot%5D/subscriptions",
            "organizations_url" : "https://api.github.com/users/bkeepers-dev%5Bbot%5D/orgs",
            "gravatar_id" : "",
            "gists_url" : "https://api.github.com/users/bkeepers-dev%5Bbot%5D/gists{/gist_id}",
            "received_events_url" : "https://api.github.com/users/bkeepers-dev%5Bbot%5D/received_events",
            "url" : "https://api.github.com/users/bkeepers-dev%5Bbot%5D",
            "followers_url" : "https://api.github.com/users/bkeepers-dev%5Bbot%5D/followers",
            "avatar_url" : "https://avatars2.githubusercontent.com/u/11724939?v=4"
         },
         "url" : "https://api.github.com/repos/robotland/test/issues/comments/398615142",
         "created_at" : "2018-06-20T03:44:47Z",
         "node_id" : "MDEyOklzc3VlQ29tbWVudDM5ODYxNTE0Mg==",
         "id" : 398615142,
         "updated_at" : "2018-06-20T03:44:47Z",
         "html_url" : "https://github.com/robotland/test/issues/159#issuecomment-398615142",
         "issue_url" : "https://api.github.com/repos/robotland/test/issues/159",
         "author_association" : "NONE"
      },
      "repository" : {
         "language" : "JavaScript",
         "comments_url" : "https://api.github.com/repos/robotland/test/comments{/number}",
         "ssh_url" : "git@github.com:robotland/test.git",
         "trees_url" : "https://api.github.com/repos/robotland/test/git/trees{/sha}",
         "merges_url" : "https://api.github.com/repos/robotland/test/merges",
         "languages_url" : "https://api.github.com/repos/robotland/test/languages",
         "notifications_url" : "https://api.github.com/repos/robotland/test/notifications{?since,all,participating}",
         "tags_url" : "https://api.github.com/repos/robotland/test/tags",
         "html_url" : "https://github.com/robotland/test",
         "id" : 68474533,
         "stargazers_url" : "https://api.github.com/repos/robotland/test/stargazers",
         "license" : null,
         "git_url" : "git://github.com/robotland/test.git",
         "url" : "https://api.github.com/repos/robotland/test",
         "issue_events_url" : "https://api.github.com/repos/robotland/test/issues/events{/number}",
         "git_tags_url" : "https://api.github.com/repos/robotland/test/git/tags{/sha}",
         "mirror_url" : null,
         "default_branch" : "master",
         "has_projects" : false,
         "compare_url" : "https://api.github.com/repos/robotland/test/compare/{base}...{head}",
         "watchers_count" : 0,
         "forks_url" : "https://api.github.com/repos/robotland/test/forks",
         "homepage" : "https://probot.github.io/",
         "has_pages" : false,
         "blobs_url" : "https://api.github.com/repos/robotland/test/git/blobs{/sha}",
         "watchers" : 0,
         "git_commits_url" : "https://api.github.com/repos/robotland/test/git/commits{/sha}",
         "contents_url" : "https://api.github.com/repos/robotland/test/contents/{+path}",
         "events_url" : "https://api.github.com/repos/robotland/test/events",
         "deployments_url" : "https://api.github.com/repos/robotland/test/deployments",
         "clone_url" : "https://github.com/robotland/test.git",
         "stargazers_count" : 0,
         "full_name" : "robotland/test",
         "git_refs_url" : "https://api.github.com/repos/robotland/test/git/refs{/sha}",
         "statuses_url" : "https://api.github.com/repos/robotland/test/statuses/{sha}",
         "assignees_url" : "https://api.github.com/repos/robotland/test/assignees{/user}",
         "description" : "a trainable robot that responds to activity on GitHub",
         "name" : "test",
         "subscribers_url" : "https://api.github.com/repos/robotland/test/subscribers",
         "open_issues_count" : 5,
         "pulls_url" : "https://api.github.com/repos/robotland/test/pulls{/number}",
         "labels_url" : "https://api.github.com/repos/robotland/test/labels{/name}",
         "forks_count" : 0,
         "node_id" : "MDEwOlJlcG9zaXRvcnk2ODQ3NDUzMw==",
         "owner" : {
            "id" : 11724939,
            "site_admin" : false,
            "starred_url" : "https://api.github.com/users/robotland/starred{/owner}{/repo}",
            "html_url" : "https://github.com/robotland",
            "events_url" : "https://api.github.com/users/robotland/events{/privacy}",
            "repos_url" : "https://api.github.com/users/robotland/repos",
            "node_id" : "MDEyOk9yZ2FuaXphdGlvbjExNzI0OTM5",
            "following_url" : "https://api.github.com/users/robotland/following{/other_user}",
            "login" : "robotland",
            "organizations_url" : "https://api.github.com/users/robotland/orgs",
            "gists_url" : "https://api.github.com/users/robotland/gists{/gist_id}",
            "gravatar_id" : "",
            "subscriptions_url" : "https://api.github.com/users/robotland/subscriptions",
            "type" : "Organization",
            "followers_url" : "https://api.github.com/users/robotland/followers",
            "url" : "https://api.github.com/users/robotland",
            "avatar_url" : "https://avatars2.githubusercontent.com/u/11724939?v=4",
            "received_events_url" : "https://api.github.com/users/robotland/received_events"
         },
         "private" : true,
         "keys_url" : "https://api.github.com/repos/robotland/test/keys{/key_id}",
         "size" : 54,
         "has_issues" : true,
         "contributors_url" : "https://api.github.com/repos/robotland/test/contributors",
         "issues_url" : "https://api.github.com/repos/robotland/test/issues{/number}",
         "forks" : 0,
         "fork" : false,
         "downloads_url" : "https://api.github.com/repos/robotland/test/downloads",
         "milestones_url" : "https://api.github.com/repos/robotland/test/milestones{/number}",
         "collaborators_url" : "https://api.github.com/repos/robotland/test/collaborators{/collaborator}",
         "teams_url" : "https://api.github.com/repos/robotland/test/teams",
         "commits_url" : "https://api.github.com/repos/robotland/test/commits{/sha}",
         "archived" : false,
         "created_at" : "2016-09-17T19:44:06Z",
         "svn_url" : "https://github.com/robotland/test",
         "has_downloads" : true,
         "branches_url" : "https://api.github.com/repos/robotland/test/branches{/branch}",
         "has_wiki" : false,
         "hooks_url" : "https://api.github.com/repos/robotland/test/hooks",
         "open_issues" : 5,
         "updated_at" : "2018-04-05T00:01:35Z",
         "issue_comment_url" : "https://api.github.com/repos/robotland/test/issues/comments{/number}",
         "archive_url" : "https://api.github.com/repos/robotland/test/{archive_format}{/ref}",
         "pushed_at" : "2018-04-05T00:01:34Z",
         "releases_url" : "https://api.github.com/repos/robotland/test/releases{/id}",
         "subscription_url" : "https://api.github.com/repos/robotland/test/subscription"
      },
      "organization" : {
         "hooks_url" : "https://api.github.com/orgs/robotland/hooks",
         "public_members_url" : "https://api.github.com/orgs/robotland/public_members{/member}",
         "description" : null,
         "node_id" : "MDEyOk9yZ2FuaXphdGlvbjExNzI0OTM5",
         "repos_url" : "https://api.github.com/orgs/robotland/repos",
         "url" : "https://api.github.com/orgs/robotland",
         "avatar_url" : "https://avatars2.githubusercontent.com/u/11724939?v=4",
         "issues_url" : "https://api.github.com/orgs/robotland/issues",
         "id" : 11724939,
         "members_url" : "https://api.github.com/orgs/robotland/members{/member}",
         "login" : "robotland",
         "events_url" : "https://api.github.com/orgs/robotland/events"
      },
      "sender" : {
         "site_admin" : false,
         "starred_url" : "https://api.github.com/users/bkeepers-dev%5Bbot%5D/starred{/owner}{/repo}",
         "html_url" : "https://github.com/apps/bkeepers-dev",
         "id" : 38381849,
         "events_url" : "https://api.github.com/users/bkeepers-dev%5Bbot%5D/events{/privacy}",
         "repos_url" : "https://api.github.com/users/bkeepers-dev%5Bbot%5D/repos",
         "node_id" : "MDM6Qm90MzgzODE4NDk=",
         "login" : "bkeepers-dev[bot]",
         "following_url" : "https://api.github.com/users/bkeepers-dev%5Bbot%5D/following{/other_user}",
         "type" : "Bot",
         "subscriptions_url" : "https://api.github.com/users/bkeepers-dev%5Bbot%5D/subscriptions",
         "organizations_url" : "https://api.github.com/users/bkeepers-dev%5Bbot%5D/orgs",
         "gists_url" : "https://api.github.com/users/bkeepers-dev%5Bbot%5D/gists{/gist_id}",
         "gravatar_id" : "",
         "received_events_url" : "https://api.github.com/users/bkeepers-dev%5Bbot%5D/received_events",
         "avatar_url" : "https://avatars2.githubusercontent.com/u/11724939?v=4",
         "followers_url" : "https://api.github.com/users/bkeepers-dev%5Bbot%5D/followers",
         "url" : "https://api.github.com/users/bkeepers-dev%5Bbot%5D"
      },
      "issue" : {
         "node_id" : "MDU6SXNzdWUzMzM5MTM5ODY=",
         "labels_url" : "https://api.github.com/repos/robotland/test/issues/159/labels{/name}",
         "comments" : 1,
         "title" : "One more time",
         "created_at" : "2018-06-20T03:44:43Z",
         "state" : "open",
         "assignees" : [],
         "id" : 333913986,
         "assignee" : null,
         "updated_at" : "2018-06-20T03:44:47Z",
         "html_url" : "https://github.com/robotland/test/issues/159",
         "milestone" : null,
         "author_association" : "CONTRIBUTOR",
         "repository_url" : "https://api.github.com/repos/robotland/test",
         "closed_at" : null,
         "locked" : false,
         "events_url" : "https://api.github.com/repos/robotland/test/issues/159/events",
         "user" : {
            "type" : "User",
            "subscriptions_url" : "https://api.github.com/users/bkeepers/subscriptions",
            "gists_url" : "https://api.github.com/users/bkeepers/gists{/gist_id}",
            "organizations_url" : "https://api.github.com/users/bkeepers/orgs",
            "gravatar_id" : "",
            "received_events_url" : "https://api.github.com/users/bkeepers/received_events",
            "followers_url" : "https://api.github.com/users/bkeepers/followers",
            "avatar_url" : "https://avatars0.githubusercontent.com/u/173?v=4",
            "url" : "https://api.github.com/users/bkeepers",
            "login" : "bkeepers",
            "following_url" : "https://api.github.com/users/bkeepers/following{/other_user}",
            "node_id" : "MDQ6VXNlcjE3Mw==",
            "repos_url" : "https://api.github.com/users/bkeepers/repos",
            "id" : 173,
            "html_url" : "https://github.com/bkeepers",
            "site_admin" : true,
            "starred_url" : "https://api.github.com/users/bkeepers/starred{/owner}{/repo}",
            "events_url" : "https://api.github.com/users/bkeepers/events{/privacy}"
         },
         "body" : "/remind me to do in in 5 min\n\n<!-- probot = {\"198506\":{\"who\":\"bkeepers\",\"what\":\"do in\",\"when\":\"2018-06-20T03:49:44.000Z\"}} -->",
         "comments_url" : "https://api.github.com/repos/robotland/test/issues/159/comments",
         "url" : "https://api.github.com/repos/robotland/test/issues/159",
         "labels" : [
            {
               "color" : "ededed",
               "default" : false,
               "url" : "https://api.github.com/repos/robotland/test/labels/reminder",
               "node_id" : "MDU6TGFiZWw2ODk3MDUxODA=",
               "id" : 689705180,
               "name" : "reminder"
            }
         ],
         "number" : 159
      },
      "installation" : {
         "id" : 198506
      }
   }
}

So we’d either want a app.receive method that could take this object as an argument, or somehow make changes to the smee payload to make it compatible with what can currently be injected into Probot.

Teachability, Documentation, Adoption, Migration Strategy

const {Application} = require('probot')
const app = new Application()
app.load(require('path/to/my/app'))


// where push.json is a copy of the payload from smee.io
app.receive(require('test/fixtures/push.json'))

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
gautamaroracommented, Jul 18, 2018

thanks for taking care of this @JasonEtco!! copy pasting smee payloads as fixtures works smoothly now!!

for future reference, fix was made here

0reactions
JasonEtcocommented, Jul 18, 2018

Awesome, glad its helped @gautamarora! I’ll go ahead and close this, since https://github.com/probot/smee/pull/66 has been merged an deployed.

Read more comments on GitHub >

github_iconTop Results From Across the Web

testfixtures/README.md at master - GitHub
Basically this package mimics the "Ruby on Rails' way" of writing tests for database applications, where sample data is kept in fixtures files....
Read more >
Working with fixture data in your tests - Michael Dyrynda
We can then load these fixtures from the tests/fixtures/ directory and reference a specific payload using the loadFixture helper.
Read more >
Loading Data with Fixtures - YouTube
We will use fixture data to seed our application state. As we iterate on our test and app code, we will create and...
Read more >
Rails Testing Antipatterns: Fixtures and Factories - Semaphore
Get familiar with common antipatterns in writing tests for Rails applications when using fixtures and/or factories to manage dependencies.
Read more >
Efficient testing with fixtures on Symfony 4 | by Pablo Godinez
Fixtures are used to load a “fake” set of data into a database that can then be used for testing or help give...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found