{"action":"created","issue":{"url":"https://api.github.com/repos/sindresorhus/gulp-mocha/issues/54","labels_url":"https://api.github.com/repos/sindresorhus/gulp-mocha/issues/54/labels{/name}","comments_url":"https://api.github.com/repos/sindresorhus/gulp-mocha/issues/54/comments","events_url":"https://api.github.com/repos/sindresorhus/gulp-mocha/issues/54/events","html_url":"https://github.com/sindresorhus/gulp-mocha/issues/54","id":41481609,"number":54,"title":"Gulp-Mocha fails to exit, but Mocha does","user":{"login":"drundle","id":8349915,"avatar_url":"https://avatars.githubusercontent.com/u/8349915?v=3","gravatar_id":"","url":"https://api.github.com/users/drundle","html_url":"https://github.com/drundle","followers_url":"https://api.github.com/users/drundle/followers","following_url":"https://api.github.com/users/drundle/following{/other_user}","gists_url":"https://api.github.com/users/drundle/gists{/gist_id}","starred_url":"https://api.github.com/users/drundle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/drundle/subscriptions","organizations_url":"https://api.github.com/users/drundle/orgs","repos_url":"https://api.github.com/users/drundle/repos","events_url":"https://api.github.com/users/drundle/events{/privacy}","received_events_url":"https://api.github.com/users/drundle/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":41,"created_at":"2014-08-29T08:48:05Z","updated_at":"2015-01-04T16:08:45Z","closed_at":"2015-01-04T09:23:33Z","body":"Hi,\r\n\r\nI am running a simple test (its failing, but that a separate issue).\r\n\r\nUsing:\r\n\r\n    \"gulp-mocha\": \"^1.0.0\",\r\n\r\n\r\nWhen I run this using Gulp-Mocha (it happens on Travis as well), it does not exit the testing execution, but when I run this using Mocha, it fails, and exits back to the command prompt.\r\n\r\n\tvar assert = require(\"assert\"),\r\n\t\telasticsearch = require('elasticsearch'),\r\n\t\tclient;\r\n\r\n\t\tclient = new elasticsearch.Client();\r\n\t\t\r\n\t\tdescribe(' people', function(){\r\n\r\n\t\tbeforeEach(function(done){\r\n\t\t  \r\n\t\t\t//in Gulp Mocha this stops the test runner exiting\r\n\t\t\t//that this does not work is not this issue.\r\n\t\t\tclient.deleteByQuery({\r\n\t\t\t\tindex: 'people',\r\n\t\t\t\tq: '*'\r\n\t\t\t}, function (error, response) {\r\n\t\t\t\tdone();\r\n\t\t\t});\r\n\r\n\r\n\t\t   //If i just do done(), it will exit. in both.\r\n\t\t   //done();\r\n\r\n\t\t});\r\n\r\n\t\tdescribe('add a entry into the index', function(){\r\n\t\t\tit('should add Dave as a person to the database', function(done){\r\n\t\t\t\tassert.equal(1,1);\r\n\t\t\t});\r\n\t\t});\r\n\t});"},"comment":{"url":"https://api.github.com/repos/sindresorhus/gulp-mocha/issues/comments/68637912","html_url":"https://github.com/sindresorhus/gulp-mocha/issues/54#issuecomment-68637912","issue_url":"https://api.github.com/repos/sindresorhus/gulp-mocha/issues/54","id":68637912,"user":{"login":"juanpabloaj","id":732415,"avatar_url":"https://avatars.githubusercontent.com/u/732415?v=3","gravatar_id":"","url":"https://api.github.com/users/juanpabloaj","html_url":"https://github.com/juanpabloaj","followers_url":"https://api.github.com/users/juanpabloaj/followers","following_url":"https://api.github.com/users/juanpabloaj/following{/other_user}","gists_url":"https://api.github.com/users/juanpabloaj/gists{/gist_id}","starred_url":"https://api.github.com/users/juanpabloaj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/juanpabloaj/subscriptions","organizations_url":"https://api.github.com/users/juanpabloaj/orgs","repos_url":"https://api.github.com/users/juanpabloaj/repos","events_url":"https://api.github.com/users/juanpabloaj/events{/privacy}","received_events_url":"https://api.github.com/users/juanpabloaj/received_events","type":"User","site_admin":false},"created_at":"2015-01-04T16:08:45Z","updated_at":"2015-01-04T16:08:45Z","body":"If, I use `process.exit()` this kill the `gulp.watch` .\r\n\r\nI try with this test code (without database connections) :\r\n\r\nhttps://gist.github.com/juanpabloaj/f1ea60417f47897c940f\r\n\r\n``` javascript\r\ndescribe('app test', function(){\r\n  it('app return json message', function(done){\r\n    request(app)\r\n      .get('/')\r\n      .expect(200)\r\n      .end(function(err, res){\r\n        res.body.message.should.match(/test/);\r\n        done();\r\n      });\r\n  });\r\n});\r\n```\r\n\r\nwhen I use `mocha -w test_app.js`, work fine\r\n\r\n``` bash\r\n$ mocha -w test_app.js\r\n\r\n  app test\r\n    ✓ app return json message\r\n\r\n  1 passing (49ms)\r\n\r\n  app test\r\n    ✓ app return json message\r\n\r\n  1 passing (13ms)\r\n```\r\n\r\nbut, If I use `gulp`, only the first time work fine\r\n\r\n```bash\r\n$ gulp\r\n[13:04:22] Using gulpfile ~/code/nodejs/gupl-mocha/fail_to_exit/gulpfile.js\r\n[13:04:22] Starting 'watch'...\r\n[13:04:22] Finished 'watch' after 8.98 ms\r\n[13:04:22] Starting 'default'...\r\n[13:04:22] Finished 'default' after 8.52 μs\r\n[13:04:25] Starting 'tests'...\r\n\r\n\r\n  app test\r\n    ✓ app return json message\r\n\r\n\r\n  1 passing (23ms)\r\n\r\n[13:04:26] Finished 'tests' after 358 ms\r\n[13:04:28] Starting 'tests'...\r\n\r\n\r\n[13:04:28] 'tests' errored after 154 ms\r\n[13:04:28] Error in plugin 'gulp-mocha'\r\nMessage:\r\n    listen EADDRINUSE\r\nDetails:\r\n    code: EADDRINUSE\r\n    errno: EADDRINUSE\r\n    syscall: listen\r\n    domainEmitter: [object Object]\r\n    domain: [object Object]\r\n    domainThrown: false\r\nStack:\r\nError: listen EADDRINUSE\r\n    at errnoException (net.js:904:11)\r\n    at Server._listen2 (net.js:1042:14)\r\n    at listen (net.js:1064:10)\r\n    at Server.listen (net.js:1138:5)\r\n    at EventEmitter.app.listen (/Users/pablo/code/nodejs/gupl-mocha/fail_to_exit/node_modules/express/lib/application.js:559:24)\r\n    at Object.<anonymous> (/Users/pablo/code/nodejs/gupl-mocha/fail_to_exit/server.js:15:5)\r\n    at Module._compile (module.js:456:26)\r\n    at Object.Module._extensions..js (module.js:474:10)\r\n    at Module.load (module.js:356:32)\r\n    at Function.Module._load (module.js:312:12)\r\n  app test\r\n    ✓ app return json message\r\n\r\n\r\n  1 passing (13ms)\r\n```"}}