{"action":"created","issue":{"url":"https://api.github.com/repos/testdouble/testdouble.js/issues/119","repository_url":"https://api.github.com/repos/testdouble/testdouble.js","labels_url":"https://api.github.com/repos/testdouble/testdouble.js/issues/119/labels{/name}","comments_url":"https://api.github.com/repos/testdouble/testdouble.js/issues/119/comments","events_url":"https://api.github.com/repos/testdouble/testdouble.js/issues/119/events","html_url":"https://github.com/testdouble/testdouble.js/issues/119","id":165864257,"number":119,"title":"td.replace doesn't properly detect ES6 classes","user":{"login":"monkbroc","id":1919681,"avatar_url":"https://avatars.githubusercontent.com/u/1919681?v=3","gravatar_id":"","url":"https://api.github.com/users/monkbroc","html_url":"https://github.com/monkbroc","followers_url":"https://api.github.com/users/monkbroc/followers","following_url":"https://api.github.com/users/monkbroc/following{/other_user}","gists_url":"https://api.github.com/users/monkbroc/gists{/gist_id}","starred_url":"https://api.github.com/users/monkbroc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/monkbroc/subscriptions","organizations_url":"https://api.github.com/users/monkbroc/orgs","repos_url":"https://api.github.com/users/monkbroc/repos","events_url":"https://api.github.com/users/monkbroc/events{/privacy}","received_events_url":"https://api.github.com/users/monkbroc/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-07-15T19:50:28Z","updated_at":"2016-07-15T19:51:31Z","closed_at":null,"body":"When using Node 6 with ES6 classes the `td.replace` call doesn't properly detect ES6 classes as constructors because the methods of ES6 classes are not enumerable. The constructor is not wrapped as expected.\r\n\r\nThe affected line is https://github.com/testdouble/testdouble.js/blob/65251fe625574aea0569140768f993641d53620f/src/replace/is-constructor.coffee#L5\r\n\r\nTest case to reproduce:\r\n\r\n```\r\n# index.js\r\nconst td = require('testdouble');\r\nconst MyES5Class = td.replace('./MyES5Class');\r\nconst MyES6Class = td.replace('./MyES6Class');\r\n\r\ntd.when(MyES5Class.mymethod()).thenReturn(5); // <-- works\r\ntd.when(MyES6Class.mymethod()).thenReturn(6); // <-- MyES6Class.mymethod is not a function\r\n\r\n# MyES5Class.js\r\nfunction MyES5Class() {}\r\nMyES5Class.prototype.mymethod = function () {\r\n  return 0;\r\n};\r\n\r\nmodule.exports = MyES5Class;\r\n\r\n# MyES6Class.js\r\nclass MyES6Class {\r\n  constructor() {}\r\n  mymethod() {\r\n    return 0;\r\n  }\r\n}\r\n\r\nmodule.exports = MyES6Class;\r\n```"},"comment":{"url":"https://api.github.com/repos/testdouble/testdouble.js/issues/comments/233053714","html_url":"https://github.com/testdouble/testdouble.js/issues/119#issuecomment-233053714","issue_url":"https://api.github.com/repos/testdouble/testdouble.js/issues/119","id":233053714,"user":{"login":"searls","id":79303,"avatar_url":"https://avatars.githubusercontent.com/u/79303?v=3","gravatar_id":"","url":"https://api.github.com/users/searls","html_url":"https://github.com/searls","followers_url":"https://api.github.com/users/searls/followers","following_url":"https://api.github.com/users/searls/following{/other_user}","gists_url":"https://api.github.com/users/searls/gists{/gist_id}","starred_url":"https://api.github.com/users/searls/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/searls/subscriptions","organizations_url":"https://api.github.com/users/searls/orgs","repos_url":"https://api.github.com/users/searls/repos","events_url":"https://api.github.com/users/searls/events{/privacy}","received_events_url":"https://api.github.com/users/searls/received_events","type":"User","site_admin":false},"created_at":"2016-07-15T19:51:31Z","updated_at":"2016-07-15T19:51:31Z","body":"Hey thanks for opening this!  Ideas on how to implement. I'm not very familiar with ES6 classes—what introspection is available?"}}
{"actor":{"display_login":"searls"}}