{"action":"created","issue":{"url":"https://api.github.com/repos/mavdi/grunt-cucumberjs/issues/71","repository_url":"https://api.github.com/repos/mavdi/grunt-cucumberjs","labels_url":"https://api.github.com/repos/mavdi/grunt-cucumberjs/issues/71/labels{/name}","comments_url":"https://api.github.com/repos/mavdi/grunt-cucumberjs/issues/71/comments","events_url":"https://api.github.com/repos/mavdi/grunt-cucumberjs/issues/71/events","html_url":"https://github.com/mavdi/grunt-cucumberjs/issues/71","id":159382020,"number":71,"title":"Fails to parse JSON (and create HTML output) on cucumber error","user":{"login":"shaneobrien20","id":19835703,"avatar_url":"https://avatars.githubusercontent.com/u/19835703?v=3","gravatar_id":"","url":"https://api.github.com/users/shaneobrien20","html_url":"https://github.com/shaneobrien20","followers_url":"https://api.github.com/users/shaneobrien20/followers","following_url":"https://api.github.com/users/shaneobrien20/following{/other_user}","gists_url":"https://api.github.com/users/shaneobrien20/gists{/gist_id}","starred_url":"https://api.github.com/users/shaneobrien20/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shaneobrien20/subscriptions","organizations_url":"https://api.github.com/users/shaneobrien20/orgs","repos_url":"https://api.github.com/users/shaneobrien20/repos","events_url":"https://api.github.com/users/shaneobrien20/events{/privacy}","received_events_url":"https://api.github.com/users/shaneobrien20/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2016-06-09T11:06:35Z","updated_at":"2016-06-10T15:58:47Z","closed_at":null,"body":"First of all great work on this, very impressive reporting outputs!\r\n\r\nHowever we found 1 issue where the cucumber json output was not being parsed for the html report to be generated. When a test failed with a cucumber error output, it generated the output json in processHandler.js (around line 98) with the error first, followed by the json test results, but when it tried to extract the json test results for generating the html, it incorrectly pulled the errors in as well, causing it to be invalid json and it would give the error: \"unable to parse json\".\r\n\r\nHere is an example of the output:\r\n\r\n`\r\nError: Error: This is some error thrown by cucumber.\r\nError occurred on line ........\r\n\r\n[\r\n  {\r\n    \"id\": \"This-the-id\",\r\n    \"name\": \"This the name\",\r\n    \"description\": \"A description of the object\"\r\n  },\r\n  {\r\n      \"id\": \"This-the-second-id\",\r\n      \"name\": \"This the second name\",\r\n      \"description\": \"A description of the second object\"\r\n    }\r\n]\r\n`\r\n\r\nI managed to get it working by changing the regex on line 98 in processHandler.js from this:\r\n\r\n`var featureStartIndex = jsonOutput.search(/\\[\\s*{\\s*\\\"\\[\\\"/g);`\r\n\r\nto this:\r\n\r\n`var featureStartIndex = jsonOutput.search(/\\[\\s*{\\s*\\\"/g);`\r\n\r\nIt looks for the start of the json object and extracts it from the output.\r\n\r\nThe problem seemed to be that it wasnt finding the start of the json based on the regex it was using. It seems to work now and will still generate the html report when there are cucumber errors, showing these errors on the report.\r\n\r\nIf you can find a better solution then great, but this worked for me."},"comment":{"url":"https://api.github.com/repos/mavdi/grunt-cucumberjs/issues/comments/225222869","html_url":"https://github.com/mavdi/grunt-cucumberjs/issues/71#issuecomment-225222869","issue_url":"https://api.github.com/repos/mavdi/grunt-cucumberjs/issues/71","id":225222869,"user":{"login":"gkushang","id":3663389,"avatar_url":"https://avatars.githubusercontent.com/u/3663389?v=3","gravatar_id":"","url":"https://api.github.com/users/gkushang","html_url":"https://github.com/gkushang","followers_url":"https://api.github.com/users/gkushang/followers","following_url":"https://api.github.com/users/gkushang/following{/other_user}","gists_url":"https://api.github.com/users/gkushang/gists{/gist_id}","starred_url":"https://api.github.com/users/gkushang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gkushang/subscriptions","organizations_url":"https://api.github.com/users/gkushang/orgs","repos_url":"https://api.github.com/users/gkushang/repos","events_url":"https://api.github.com/users/gkushang/events{/privacy}","received_events_url":"https://api.github.com/users/gkushang/received_events","type":"User","site_admin":false},"created_at":"2016-06-10T15:58:46Z","updated_at":"2016-06-10T15:58:46Z","body":"@shaneobrien20 @SirLenz0rlot thanks for your inputs. I agree about improving on JSON parsing and do not depend on RegEx for future compatibility. \r\n\r\nLet's not parse the JSON based on RegEx, instead read the JSON file created at the end of run. Since Cucumber's formatter `-f json: fileName.json` writes the JSON for HTML reporting, it can be used to create HTML."}}
{"actor":{"display_login":"gkushang"}}