{"action":"opened","issue":{"url":"https://api.github.com/repos/mochajs/mocha/issues/1496","labels_url":"https://api.github.com/repos/mochajs/mocha/issues/1496/labels{/name}","comments_url":"https://api.github.com/repos/mochajs/mocha/issues/1496/comments","events_url":"https://api.github.com/repos/mochajs/mocha/issues/1496/events","html_url":"https://github.com/mochajs/mocha/issues/1496","id":53713374,"number":1496,"title":"Mocha.run throws a TypeError if callback is not provided","user":{"login":"flowersinthesand","id":1095042,"avatar_url":"https://avatars.githubusercontent.com/u/1095042?v=3","gravatar_id":"","url":"https://api.github.com/users/flowersinthesand","html_url":"https://github.com/flowersinthesand","followers_url":"https://api.github.com/users/flowersinthesand/followers","following_url":"https://api.github.com/users/flowersinthesand/following{/other_user}","gists_url":"https://api.github.com/users/flowersinthesand/gists{/gist_id}","starred_url":"https://api.github.com/users/flowersinthesand/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/flowersinthesand/subscriptions","organizations_url":"https://api.github.com/users/flowersinthesand/orgs","repos_url":"https://api.github.com/users/flowersinthesand/repos","events_url":"https://api.github.com/users/flowersinthesand/events{/privacy}","received_events_url":"https://api.github.com/users/flowersinthesand/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-01-08T04:23:24Z","updated_at":"2015-01-08T04:23:24Z","closed_at":null,"body":"To reproduce the issue, install Mocha 2.1.0 and run this script on Node console.\r\n```javascript\r\nvar Mocha = require(\"mocha\");\r\nvar mocha = new Mocha();\r\nmocha.addFile(\"./test.js\");\r\nmocha.run();\r\n```\r\n\r\nHere is `test.js`\r\n```javascript\r\nit(\"nothing\", function() {});\r\n```\r\n\r\nThen, I get:\r\n```\r\nDonghwan@DONGHWAN ~/Documents/GitHub/vibe-javascript-client (master)\r\n$ node test-runner\r\n\r\n\r\n  √ nothing\r\n\r\n  1 passing (7ms)\r\n\r\n\r\nc:\\Users\\Donghwan\\Documents\\GitHub\\vibe-javascript-client\\node_modules\\mocha\\lib\\mocha.js:414\r\n          fn(failures);\r\n          ^\r\nTypeError: undefined is not a function\r\n    at done (c:\\Users\\Donghwan\\Documents\\GitHub\\vibe-javascript-client\\node_modules\\mocha\\lib\\mocha.js:414:11)\r\n    at Runner.<anonymous> (c:\\Users\\Donghwan\\Documents\\GitHub\\vibe-javascript-client\\node_modules\\mocha\\lib\\runner.js:590:5)\r\n    at Runner.emit (events.js:117:20)\r\n    at c:\\Users\\Donghwan\\Documents\\GitHub\\vibe-javascript-client\\node_modules\\mocha\\lib\\runner.js:597:10\r\n    at c:\\Users\\Donghwan\\Documents\\GitHub\\vibe-javascript-client\\node_modules\\mocha\\lib\\runner.js:518:7\r\n    at next (c:\\Users\\Donghwan\\Documents\\GitHub\\vibe-javascript-client\\node_modules\\mocha\\lib\\runner.js:248:23)\r\n    at Object._onImmediate (c:\\Users\\Donghwan\\Documents\\GitHub\\vibe-javascript-client\\node_modules\\mocha\\lib\\runner.js:276:5)\r\n    at processImmediate [as _immediateCallback] (timers.js:345:15)\r\n```\r\n\r\n2.0.1 works fine. As the [wiki page](https://github.com/mochajs/mocha/wiki/Using-mocha-programmatically) shows use of `mocha.run()`, I think it's a regression in 2.1.0. A workaround is [to pass an empty callback](https://github.com/vibe-project/vibe-javascript-client/commit/058f9d5020306cf2800e9f2862b4a773637483c5).\r\n\r\nIt looks like that https://github.com/mochajs/mocha/commit/30582e646d579ce67ef4229922651da498e79a80 is the cause. Before executing `fn(failures);`, it should check if `fn` is available."}}