Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tobi makes 500 error for later calls #77

Open
nagyv opened this issue Mar 14, 2012 · 0 comments
Open

tobi makes 500 error for later calls #77

nagyv opened this issue Mar 14, 2012 · 0 comments

Comments

@nagyv
Copy link

nagyv commented Mar 14, 2012

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: '[email protected]',
      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: '[email protected]',
        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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant