{"action":"created","issue":{"url":"https://api.github.com/repos/c3js/c3/issues/1843","repository_url":"https://api.github.com/repos/c3js/c3","labels_url":"https://api.github.com/repos/c3js/c3/issues/1843/labels{/name}","comments_url":"https://api.github.com/repos/c3js/c3/issues/1843/comments","events_url":"https://api.github.com/repos/c3js/c3/issues/1843/events","html_url":"https://github.com/c3js/c3/issues/1843","id":177760580,"number":1843,"title":"😱 Over a third of unit tests are rubbish!","user":{"login":"aendrew","id":185041,"avatar_url":"https://avatars.githubusercontent.com/u/185041?v=3","gravatar_id":"","url":"https://api.github.com/users/aendrew","html_url":"https://github.com/aendrew","followers_url":"https://api.github.com/users/aendrew/followers","following_url":"https://api.github.com/users/aendrew/following{/other_user}","gists_url":"https://api.github.com/users/aendrew/gists{/gist_id}","starred_url":"https://api.github.com/users/aendrew/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aendrew/subscriptions","organizations_url":"https://api.github.com/users/aendrew/orgs","repos_url":"https://api.github.com/users/aendrew/repos","events_url":"https://api.github.com/users/aendrew/events{/privacy}","received_events_url":"https://api.github.com/users/aendrew/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/c3js/c3/labels/needs%20tests","name":"needs tests","color":"bfdadc"},{"url":"https://api.github.com/repos/c3js/c3/labels/tests","name":"tests","color":"000000"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-09-19T11:27:15Z","updated_at":"2016-09-19T13:44:23Z","closed_at":null,"body":"I think part of why we've had so many regressive bugs added is because we're not actually unit testing huge swaths of the codebase.\r\n\r\nI ran into the following line while troubleshooting an issue for a user:\r\n\r\n`expect(true).toBeTruthy()`\r\n\r\nThis assertion *will always pass*. And it's *littered* throughout the codebase.\r\n\r\nhttps://github.com/c3js/c3/search?utf8=%E2%9C%93&q=%22expect%28true%29.toBeTruthy%28%29%22&type=Code\r\n\r\nIf you run `grep \"expect(true).toBeTruthy()\" spec/* | wc -l`, you get `140`. That means of the ~400 assertions made across all unit tests, 140 *mean absolutely nothing*.\r\n\r\nI repeat:\r\n\r\n# 140 of our unit tests test _absolutely nothing_\r\n\r\nThis is just one invalid assertion. For all we know, even more unit tests don't actually test what they're intended to test but look like they do. \r\n\r\nPart of this is how C3 was originally constructed — because of a lack of modularity and how interconnected each piece is (particularly due to a reliance on concatenation), it wasn't really that easy to import a particular part of the library and run unit tests against it — you had to deal with the entire processed library and any additional side effects caused by that.\r\n\r\nI'm not sure what the best answer is here. My thought it to just bin any unit tests with `expect(true).toBeTruthy` in them so as to reduce the coverage score, convert everything to Mocha as per #1838, and then add the appropriate tests, gradually increasing test coverage."},"comment":{"url":"https://api.github.com/repos/c3js/c3/issues/comments/247996825","html_url":"https://github.com/c3js/c3/issues/1843#issuecomment-247996825","issue_url":"https://api.github.com/repos/c3js/c3/issues/1843","id":247996825,"user":{"login":"pchaganti","id":6500,"avatar_url":"https://avatars.githubusercontent.com/u/6500?v=3","gravatar_id":"","url":"https://api.github.com/users/pchaganti","html_url":"https://github.com/pchaganti","followers_url":"https://api.github.com/users/pchaganti/followers","following_url":"https://api.github.com/users/pchaganti/following{/other_user}","gists_url":"https://api.github.com/users/pchaganti/gists{/gist_id}","starred_url":"https://api.github.com/users/pchaganti/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pchaganti/subscriptions","organizations_url":"https://api.github.com/users/pchaganti/orgs","repos_url":"https://api.github.com/users/pchaganti/repos","events_url":"https://api.github.com/users/pchaganti/events{/privacy}","received_events_url":"https://api.github.com/users/pchaganti/received_events","type":"User","site_admin":false},"created_at":"2016-09-19T13:44:22Z","updated_at":"2016-09-19T13:44:22Z","body":"👍 "}}
{"actor":{"display_login":"pchaganti"}}