{"action":"created","issue":{"url":"https://api.github.com/repos/danvk/dygraphs/issues/467","labels_url":"https://api.github.com/repos/danvk/dygraphs/issues/467/labels{/name}","comments_url":"https://api.github.com/repos/danvk/dygraphs/issues/467/comments","events_url":"https://api.github.com/repos/danvk/dygraphs/issues/467/events","html_url":"https://github.com/danvk/dygraphs/issues/467","id":48659213,"number":467,"title":"Migrate tests to Mocha","user":{"login":"danvk","id":98301,"avatar_url":"https://avatars.githubusercontent.com/u/98301?v=3","gravatar_id":"","url":"https://api.github.com/users/danvk","html_url":"https://github.com/danvk","followers_url":"https://api.github.com/users/danvk/followers","following_url":"https://api.github.com/users/danvk/following{/other_user}","gists_url":"https://api.github.com/users/danvk/gists{/gist_id}","starred_url":"https://api.github.com/users/danvk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danvk/subscriptions","organizations_url":"https://api.github.com/users/danvk/orgs","repos_url":"https://api.github.com/users/danvk/repos","events_url":"https://api.github.com/users/danvk/events{/privacy}","received_events_url":"https://api.github.com/users/danvk/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2014-11-13T16:41:25Z","updated_at":"2015-04-12T14:08:32Z","closed_at":"2015-04-12T14:08:32Z","body":"js-test-driver seems to be abandonware: its project page advertises [\"first release of 2012\"][0]. This prevents us from getting nice things like code coverage (see #463).\r\n\r\n[Mocha][1] is a more modern testing framework which is [actively developed][2]. If we used its \"TDD\" style and [Chai][3] for assertions, this migration wouldn't be too painful.\r\n\r\nHere's a before (with jstd):\r\n```javascript\r\nvar MyTestCase = TestCase(\"MyFeature\");\r\nMyTestCase.prototype.setUp = function() {\r\n  // ... runs before each test ...\r\n};\r\nMyTestCase.prototype.tearDown = function() {\r\n  // ... runs after each test ...\r\n};\r\nMyTestCase.prototype.testBehavior = function() {\r\n  assertEquals(2, 1 + 1);\r\n};\r\n```\r\n\r\nHere's an after (with Chai & Mocha):\r\n```javascript\r\nsuite(\"annotations\", function() {\r\n  setup(function() {\r\n    // ... runs before each test ...\r\n  });\r\n  teardown(function() {\r\n    // ... runs after each test ...\r\n  });\r\n\r\n  test('test1', function() {\r\n    assert.equal(1 + 1, 2);\r\n  });\r\n});\r\n```\r\n\r\ni.e. the test gets less Java-y. We'd also get to use Mocha's in-browser test runner, which is pretty shiny:\r\n\r\n![screen shot 2014-11-13 at 11 39 02 am](https://cloud.githubusercontent.com/assets/98301/5032165/b3fb7aba-6b29-11e4-8de6-f510ba12611a.png)\r\n\r\nand its command line interface:\r\n\r\n![screen shot 2014-11-13 at 11 39 32 am](https://cloud.githubusercontent.com/assets/98301/5032174/c44bce24-6b29-11e4-8cbc-f0a557b0f73d.png)\r\n\r\nWe have both of these with our current setup, but we've had to build them ourselves using PhantomJS and our fake in-browser implementation of the jstd API. Switching to Mocha/Chai would get us back on the main path of JavaScript development.\r\n\r\n[0]: https://code.google.com/p/js-test-driver/\r\n[1]: http://mochajs.org\r\n[2]: https://github.com/mochajs/mocha/commits/master\r\n[3]: http://chaijs.com/api/assert/"},"comment":{"url":"https://api.github.com/repos/danvk/dygraphs/issues/comments/92067745","html_url":"https://github.com/danvk/dygraphs/issues/467#issuecomment-92067745","issue_url":"https://api.github.com/repos/danvk/dygraphs/issues/467","id":92067745,"user":{"login":"danvk","id":98301,"avatar_url":"https://avatars.githubusercontent.com/u/98301?v=3","gravatar_id":"","url":"https://api.github.com/users/danvk","html_url":"https://github.com/danvk","followers_url":"https://api.github.com/users/danvk/followers","following_url":"https://api.github.com/users/danvk/following{/other_user}","gists_url":"https://api.github.com/users/danvk/gists{/gist_id}","starred_url":"https://api.github.com/users/danvk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danvk/subscriptions","organizations_url":"https://api.github.com/users/danvk/orgs","repos_url":"https://api.github.com/users/danvk/repos","events_url":"https://api.github.com/users/danvk/events{/privacy}","received_events_url":"https://api.github.com/users/danvk/received_events","type":"User","site_admin":false},"created_at":"2015-04-12T14:08:32Z","updated_at":"2015-04-12T14:08:32Z","body":"This is done!"}}