{"action":"closed","issue":{"url":"https://api.github.com/repos/mochajs/mocha/issues/1825","labels_url":"https://api.github.com/repos/mochajs/mocha/issues/1825/labels{/name}","comments_url":"https://api.github.com/repos/mochajs/mocha/issues/1825/comments","events_url":"https://api.github.com/repos/mochajs/mocha/issues/1825/events","html_url":"https://github.com/mochajs/mocha/issues/1825","id":100227501,"number":1825,"title":"'Timeout of 2000ms exceeded' issue with Mocha and Mongoose","user":{"login":"soaph","id":11660695,"avatar_url":"https://avatars.githubusercontent.com/u/11660695?v=3","gravatar_id":"","url":"https://api.github.com/users/soaph","html_url":"https://github.com/soaph","followers_url":"https://api.github.com/users/soaph/followers","following_url":"https://api.github.com/users/soaph/following{/other_user}","gists_url":"https://api.github.com/users/soaph/gists{/gist_id}","starred_url":"https://api.github.com/users/soaph/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/soaph/subscriptions","organizations_url":"https://api.github.com/users/soaph/orgs","repos_url":"https://api.github.com/users/soaph/repos","events_url":"https://api.github.com/users/soaph/events{/privacy}","received_events_url":"https://api.github.com/users/soaph/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-08-11T05:07:08Z","updated_at":"2015-09-10T01:03:07Z","closed_at":"2015-09-10T01:03:07Z","body":"Here is my mocha testing file `test-api.js` :\r\n```javascript\r\nvar should = require('should');\r\nvar mongoose = require('mongoose');\r\nvar request = require('supertest');\r\nvar db = require('../config/db');\r\nvar post = require('../app/models/post');\r\nvar faker = require('faker');\r\n\r\n\r\ndescribe('Post', function () {\r\n    var url = 'http://localhost:3000';\r\n\r\n    before(function (done) {\r\n        var db_url = db.url_test;\r\n        mongoose.connect(db_url, done);\r\n    });\r\n\r\n    it('should post a post and get the post back', function (done) {\r\n        var _body = {\r\n            title: faker.name.title(),\r\n            body: faker.lorem.paragraph()\r\n        };\r\n        //console.log(_body);\r\n        request(url)\r\n            .post('/api/post')\r\n            .send(_body)\r\n            .end(function (err, res) {\r\n                //if (err) {\r\n                //    console.log(err);\r\n                //    //console.log('/api/post post method failed!');\r\n                //}\r\n                //console.log('res.body: ');\r\n                //console.log(res.body);\r\n                res.body.should.have.property('url');\r\n                res.body.should.have.property('title');\r\n                res.body.should.have.property('body');\r\n                res.body.should.have.property('date');\r\n                done();\r\n            });\r\n    });\r\n\r\n    it('should get all the posts', function (done) {\r\n        request(url)\r\n            .get('/api/post')\r\n            .expect(200)\r\n            .end(function (err, res) {\r\n                if (err) {\r\n                    console.log(err);\r\n                    //console.log('/api/post get method failed!')\r\n                }\r\n                res.body.should.have.property('count');\r\n                res.body.should.have.property('limit');\r\n                res.body.should.have.property('page');\r\n                res.body.should.have.property('results');\r\n                //console.log(res.body);\r\n                done();\r\n            });\r\n    });\r\n});\r\n```\r\n\r\nI think the problem is inside the `before` function, because if I run `mongoose.connect()` inside the `server.js` (Which is the api launching js file), I can get the test passing output.\r\n\r\nBut I want to use the specific database only for testing, so I don't want to put the `mongoose.connect()` inside the `server.js` file.\r\n\r\nHere is the problematic output of `mocha`:\r\n```\r\n  Post\r\n    1) should post a post and get the post back\r\n    ✓ should get all the posts (52ms)\r\n\r\n\r\n  1 passing (2s)\r\n  1 failing\r\n\r\n  1) Post should post a post and get the post back:\r\n     Error: timeout of 2000ms exceeded. Ensure the done() callback is being called in this test.\r\n```\r\n\r\nNow I have no idea how to deal with this problem, please help me (T_T).... Thank you.!"}}