-
Notifications
You must be signed in to change notification settings - Fork 33
Open
Description
I write mocha tests using tobi to test my express app. E.g. this is a part of my tests:
describe('Registration', function(){
var mailer_send;
helper.db.connect();
beforeEach(function(){
mailer_send = sinon.stub(mailer, "send");
});
afterEach(function(){
mailer.send.restore();
});
helper.db.clear_collection('users');
helper.db.clear_collection_after('users');
it('opens registration page', function(done){
helper.browser.get('/auth/register', function(res, $){
res.should.have.status(200);
$('form#registrationForm').should.have.length(1);
$('form#registrationForm').should.have.one('input[name="password"]');
$('form#registrationForm').should.have.one('input[name="password2"]');
$('form#registrationForm').should.have.one('input[name="email"]');
$('form#registrationForm').should.have.one('input[name="name"]');
done();
});
});
it('creates new user', function(done){
/* helper.browser.post('/auth/register', {body: $.param({
name: 'testlogin',
email: 'valid@example.com',
password: 'password',
password2: 'password'
})},
function(res, $){
mailer_send.callCount.should.be.equal(2);
res.should.have.status(200);
statusapp.Users.length.should.equal(1);
helper.db.with_collection('users', function(err, collection){
collection.count({name: 'testlogin', active: false}, function(err, num){
num.should.be.equal(1);
done();
});
});
}
);*/
});
describe('fails', function(){
it('for too short password', function(done){
helper.browser.post('/auth/register', {body: $.param({
name: 'testlogin',
email: 'valid@example.com',
password: 'pa',
password2: 'pa'
})},
function(res, $){
res.statusCode.should.equal(200);
done();
}
);
});
});
});
Where helper.browser is a tobi.createBrowser(8000, "localhost");
As you can see there is a tobi called commented out. This way all the tests pass. On the other hand if I delete the comments, the last test fails with 500 error. I've tried to investigate the issue, and could not find anything useful, as even my route callbacks are not called. As already said, I would like to test an express based app with mocha.
What can go wrong here?
Metadata
Metadata
Assignees
Labels
No labels