{"action":"closed","issue":{"url":"https://api.github.com/repos/nock/nock/issues/1052","repository_url":"https://api.github.com/repos/nock/nock","labels_url":"https://api.github.com/repos/nock/nock/issues/1052/labels{/name}","comments_url":"https://api.github.com/repos/nock/nock/issues/1052/comments","events_url":"https://api.github.com/repos/nock/nock/issues/1052/events","html_url":"https://github.com/nock/nock/issues/1052","id":290667799,"node_id":"MDU6SXNzdWUyOTA2Njc3OTk=","number":1052,"title":"Confusing match failure message for mismatched request bodies","user":{"login":"uhoh-itsmaciek","id":159100,"node_id":"MDQ6VXNlcjE1OTEwMA==","avatar_url":"https://avatars1.githubusercontent.com/u/159100?v=4","gravatar_id":"","url":"https://api.github.com/users/uhoh-itsmaciek","html_url":"https://github.com/uhoh-itsmaciek","followers_url":"https://api.github.com/users/uhoh-itsmaciek/followers","following_url":"https://api.github.com/users/uhoh-itsmaciek/following{/other_user}","gists_url":"https://api.github.com/users/uhoh-itsmaciek/gists{/gist_id}","starred_url":"https://api.github.com/users/uhoh-itsmaciek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/uhoh-itsmaciek/subscriptions","organizations_url":"https://api.github.com/users/uhoh-itsmaciek/orgs","repos_url":"https://api.github.com/users/uhoh-itsmaciek/repos","events_url":"https://api.github.com/users/uhoh-itsmaciek/events{/privacy}","received_events_url":"https://api.github.com/users/uhoh-itsmaciek/received_events","type":"User","site_admin":false},"labels":[{"id":1055761077,"node_id":"MDU6TGFiZWwxMDU1NzYxMDc3","url":"https://api.github.com/repos/nock/nock/labels/stale","name":"stale","color":"ffffff","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-01-23T00:37:33Z","updated_at":"2018-09-21T21:19:37Z","closed_at":"2018-09-21T21:19:37Z","author_association":"NONE","body":"Nock currently includes the mock body in its \"failed to match\" error message, but not the request body it received. This can be very confusing. The following minimal test case:\r\n\r\n```javascript\r\nconst http = require('http')\r\nconst nock = require('nock')\r\n\r\nconst api = nock('http://example.com')\r\n\r\napi.post('/', { foo: 'bar' }).reply(200, { baz: 'quux' })\r\n\r\nconst req = http.request({\r\n  hostname: 'example.com',\r\n  method: 'POST',\r\n  path: '/',\r\n\r\n}, (res) => {\r\n  res.on('end', () => {\r\n    console.log('done')\r\n  })\r\n})\r\n\r\nreq.write(JSON.stringify({ foo: 'baz' }))\r\nreq.end()\r\n```\r\n\r\nwill complain with\r\n\r\n```\r\nError: Nock: No match for request {\r\n  \"method\": \"POST\",\r\n  \"url\": \"http://example.com/\",\r\n  \"body\": \"{\\\"foo\\\":\\\"baz\\\"}\"\r\n} Got instead {\r\n  \"method\": \"POST\",\r\n  \"url\": \"http://example.com/\"\r\n}\r\n```\r\n\r\nwhich makes it seem like nock didn't actually get a body at all (but it did get one, just one that does not match the mock). It would be great if the received body were included, or at least that the error made it clear that the bodies do not match. If I change the body to match, this works as expected.\r\n\r\nSee also #398, though filing a new issue since I think this is a distinct enough problem."}}
{"actor":{"display_login":"stale"}}