Finally I choose vows + tobi + should.js for testing.

I've put together a short post about how I made my choice:
http://dev.estisia.com/2012/02/unit-testing-node-js-applications/

On febr. 17, 09:29, Bika <[email protected]> wrote:
> ok, thanks to your links, I've managed to start writing my tests with
> Mocha and have nice errors all around my code :)
>
> but a new problem arised: how to wait for the database connection
> before my tests start running?
>
> I'm using backbone-mongodb[1] that's built on top of the native mongo
> driver
>
> I would like to purge my collection:
>
> beforeEach(function(done){
>   mainapp.statusapp.Users._withCollection(function(err, collection){
>     if(err) done(err);
>     collection.remove({}, done);
>   })
>
> });
>
> and this is called in my main app code
>
> var db = new Db({
>   name: 'test',
>   host: '127.0.0.1',
>   port: 27017});
>
> db.on('database', function(status){
>   var error = status == 'open' ? null : status;
>   if (error) throw 'Could not connect to database';
>   else {
>     statusapp.Users.fetch({
>       error: function(err) {
>         throw 'Could not fetch users';
>       },
>       success: function(results) {
>         console.log('Initial fetch success');
>       }
>     });
>   }
>
> })
>
> unfortunately putting all my tests inside a db.on call did not work,
> as the callback would have been called by the time the mocha quit
>
> [1]:https://github.com/ToolPartTeam/backbone-mongodb
>
> On febr. 17, 04:43, tjholowaychuk <[email protected]> wrote:
>
>
>
>
>
>
>
> >http://www.devthought.com/2011/12/22/a-string-is-not-an-error/
>
> > On Feb 16, 10:58 am, fent <[email protected]> wrote:
>
> > > Take a look at zombie.js  http://zombie.labnotes.org/

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Reply via email to