{"action":"created","issue":{"url":"https://api.github.com/repos/visionmedia/supertest/issues/187","repository_url":"https://api.github.com/repos/visionmedia/supertest","labels_url":"https://api.github.com/repos/visionmedia/supertest/issues/187/labels{/name}","comments_url":"https://api.github.com/repos/visionmedia/supertest/issues/187/comments","events_url":"https://api.github.com/repos/visionmedia/supertest/issues/187/events","html_url":"https://github.com/visionmedia/supertest/issues/187","id":51173502,"number":187,"title":"Supertest fails on Content-Type","user":{"login":"ilanbiala","id":3695164,"avatar_url":"https://avatars.githubusercontent.com/u/3695164?v=3","gravatar_id":"","url":"https://api.github.com/users/ilanbiala","html_url":"https://github.com/ilanbiala","followers_url":"https://api.github.com/users/ilanbiala/followers","following_url":"https://api.github.com/users/ilanbiala/following{/other_user}","gists_url":"https://api.github.com/users/ilanbiala/gists{/gist_id}","starred_url":"https://api.github.com/users/ilanbiala/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ilanbiala/subscriptions","organizations_url":"https://api.github.com/users/ilanbiala/orgs","repos_url":"https://api.github.com/users/ilanbiala/repos","events_url":"https://api.github.com/users/ilanbiala/events{/privacy}","received_events_url":"https://api.github.com/users/ilanbiala/received_events","type":"User","site_admin":false},"labels":[{"id":7951647,"url":"https://api.github.com/repos/visionmedia/supertest/labels/question","name":"question","color":"cc317c","default":true}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":13,"created_at":"2014-12-06T06:34:54Z","updated_at":"2016-11-14T16:01:47Z","closed_at":"2015-05-21T01:44:24Z","body":"Supertest says the content-type is text/plain, but when I use Postman or Chrome devtools and check the network tab, it correctly shows the content-type as text/html.\n\n```\ndescribe('Core controller unit tests:', function() {\n    before(function(done) {\n        request = request('http://localhost:3001');\n\n        done();\n    });\n\n    describe('Loading the homepage', function() {\n        it('should return 200 from GET /', function(done) {\n            request\n                .get('/')\n                .expect('Content-Type', /html/)\n                .expect(200, done);\n        });\n    });\n\n    after(function(done) {\n        done();\n    });\n});\n```\n"},"comment":{"url":"https://api.github.com/repos/visionmedia/supertest/issues/comments/260376454","html_url":"https://github.com/visionmedia/supertest/issues/187#issuecomment-260376454","issue_url":"https://api.github.com/repos/visionmedia/supertest/issues/187","id":260376454,"user":{"login":"TeemuKoivisto","id":10279942,"avatar_url":"https://avatars.githubusercontent.com/u/10279942?v=3","gravatar_id":"","url":"https://api.github.com/users/TeemuKoivisto","html_url":"https://github.com/TeemuKoivisto","followers_url":"https://api.github.com/users/TeemuKoivisto/followers","following_url":"https://api.github.com/users/TeemuKoivisto/following{/other_user}","gists_url":"https://api.github.com/users/TeemuKoivisto/gists{/gist_id}","starred_url":"https://api.github.com/users/TeemuKoivisto/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TeemuKoivisto/subscriptions","organizations_url":"https://api.github.com/users/TeemuKoivisto/orgs","repos_url":"https://api.github.com/users/TeemuKoivisto/repos","events_url":"https://api.github.com/users/TeemuKoivisto/events{/privacy}","received_events_url":"https://api.github.com/users/TeemuKoivisto/received_events","type":"User","site_admin":false},"created_at":"2016-11-14T16:01:47Z","updated_at":"2016-11-14T16:01:47Z","body":"Just FYI for other dummies like me whose tests failed on ```.expect(\"Content-Type\", /json/)```\r\n\r\nMy mistake was refactoring this bit of code from \r\n```\r\nres.status(statusCode).send(err); // err is an object\r\n```\r\nto\r\n```\r\nres.status(statusCode).send(message); // string from the err object\r\n```\r\nWhen the correct way would be\r\n```\r\nres.status(statusCode).send({ message, });\r\n```\r\n\r\n\r\nBy default if the data is not inside curly brackets it will be rendered as html, not json. And the reason why I couldn't see it with Postman was because it still sends err-objects while in development environment, not test. Every day I relearn something new..."}}
{"actor":{"display_login":"TeemuKoivisto"}}