{"action":"created","issue":{"url":"https://api.github.com/repos/uberVU/mocha-mugshot-reporter/issues/4","labels_url":"https://api.github.com/repos/uberVU/mocha-mugshot-reporter/issues/4/labels{/name}","comments_url":"https://api.github.com/repos/uberVU/mocha-mugshot-reporter/issues/4/comments","events_url":"https://api.github.com/repos/uberVU/mocha-mugshot-reporter/issues/4/events","html_url":"https://github.com/uberVU/mocha-mugshot-reporter/pull/4","id":105998977,"number":4,"title":"Report generator","user":{"login":"flore77","id":11819686,"avatar_url":"https://avatars.githubusercontent.com/u/11819686?v=3","gravatar_id":"","url":"https://api.github.com/users/flore77","html_url":"https://github.com/flore77","followers_url":"https://api.github.com/users/flore77/followers","following_url":"https://api.github.com/users/flore77/following{/other_user}","gists_url":"https://api.github.com/users/flore77/gists{/gist_id}","starred_url":"https://api.github.com/users/flore77/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/flore77/subscriptions","organizations_url":"https://api.github.com/users/flore77/orgs","repos_url":"https://api.github.com/users/flore77/repos","events_url":"https://api.github.com/users/flore77/events{/privacy}","received_events_url":"https://api.github.com/users/flore77/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":9,"created_at":"2015-09-11T12:16:51Z","updated_at":"2015-09-22T13:23:09Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/uberVU/mocha-mugshot-reporter/pulls/4","html_url":"https://github.com/uberVU/mocha-mugshot-reporter/pull/4","diff_url":"https://github.com/uberVU/mocha-mugshot-reporter/pull/4.diff","patch_url":"https://github.com/uberVU/mocha-mugshot-reporter/pull/4.patch"},"body":"## Need\r\n\r\n```gherkin\r\nAs a developer\r\nI need to have all my html/js/css files in one place \r\nSo that I can present a good nice styled report to the user\r\n```\r\n\r\n## Deliverables\r\n\r\nCreate a `rootDirectory` and will put all the needed files to present the report in it.\r\n\r\n- [x] a file with the data from the `Mocha runner`. (i.e `data.js`)\r\n- [x] copy all files from `statics` to `rootDirectory`\r\n- [x] make the `rootDirectory` parametrised  \r\n\r\n## Solution\r\n\r\nWe will build a `node module`, that will receive our `data` (check out #6 and #3). It will create the `rootDirectory`, (default  **visual-report**) and put all the files in it.\r\n\r\n```js\r\nmodule.exports = function(data, cb) {\r\n\r\n}\r\n```\r\n\r\nThe `data.js` file will contain a variable with the stringified data, because we want to retrieve this data in a global var in the browser.\r\n\r\nBut to achieve this, our `reporter` must implement a `done method`, because otherwise `Mocha` will exit early and our callbacks have no chance to be executed.\r\n\r\nIn the constructor, we will put the data on `this`:\r\n```js\r\ngenerateData(runner, function(data) {\r\n  this.data = data;\r\n});\r\n```\r\n\r\nThe `done` method:\r\n```\r\nMugshotReporter.prototype.done = function(failures, fn) {\r\n  generateReport(this.data, function(error) {\r\n    fn(failures);\r\n  });\r\n}\r\n```\r\n\r\n**This works, because the `done` method is called after the `end` event was emitted, and the callback from `generateData` was executed.**"},"comment":{"url":"https://api.github.com/repos/uberVU/mocha-mugshot-reporter/issues/comments/142288373","html_url":"https://github.com/uberVU/mocha-mugshot-reporter/pull/4#issuecomment-142288373","issue_url":"https://api.github.com/repos/uberVU/mocha-mugshot-reporter/issues/4","id":142288373,"user":{"login":"andrei-picus-hs","id":12442713,"avatar_url":"https://avatars.githubusercontent.com/u/12442713?v=3","gravatar_id":"","url":"https://api.github.com/users/andrei-picus-hs","html_url":"https://github.com/andrei-picus-hs","followers_url":"https://api.github.com/users/andrei-picus-hs/followers","following_url":"https://api.github.com/users/andrei-picus-hs/following{/other_user}","gists_url":"https://api.github.com/users/andrei-picus-hs/gists{/gist_id}","starred_url":"https://api.github.com/users/andrei-picus-hs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andrei-picus-hs/subscriptions","organizations_url":"https://api.github.com/users/andrei-picus-hs/orgs","repos_url":"https://api.github.com/users/andrei-picus-hs/repos","events_url":"https://api.github.com/users/andrei-picus-hs/events{/privacy}","received_events_url":"https://api.github.com/users/andrei-picus-hs/received_events","type":"User","site_admin":false},"created_at":"2015-09-22T13:23:09Z","updated_at":"2015-09-22T13:23:09Z","body":"Finished review."}}