Skip to content

Instantly share code, notes, and snippets.

@bingomanatee
Created November 24, 2011 03:21
Show Gist options
  • Save bingomanatee/1390560 to your computer and use it in GitHub Desktop.
Save bingomanatee/1390560 to your computer and use it in GitHub Desktop.
mocha test ... why?
describe('basic', function () {
var app;
var content = 'hello world';
before(function (done) {
console.log('requiring server');
//app = require('./strata_server/app');
// console.log('server: ', util.inspect(app));
done();
});
describe('#body', function (done) {
console.log('mock request');
/* mock.request({requestMethod:"GET"}, app,
function (err, status, headers, body) {
console.log('err', util.inspect(err));
console.log('status', util.inspect(status));
console.log('headers', util.inspect(headers));
console.log('body', body);
if (body != content) throw new Error('body (' + body + ') is not content');
done();
}); */
done();
});
});
@bingomanatee
Copy link
Author

getting some odd behavior

Acropolis:nuby-strata dave$ mocha -s 100
mock request

node.js:201
throw e; // process.nextTick error, or 'error' event on first tick
^
TypeError: undefined is not a function
at /Users/dave/Documents/AC_Strata/node_modules/nuby-strata/test/strata.js:26:9
at /opt/local/lib/node_modules/mocha/lib/interfaces/bdd.js:72:7

note that 'requiring server' in before (or beforeEach) doesn't fire off, and the passed callback (done) from line 11 is not recognized as a function.

@tj
Copy link

tj commented Nov 24, 2011

hmm, appears fine to me:

describe('basic', function(){
  var app;
  before(function(done){
    console.log('before');
    done()
  })

  describe('#body', function(){
    it('should do stuff', function(done){
      console.log('test');
      done()
    })
  })
})
$ mocha test

  before
test
.

  ✔ 1 tests complete (3ms)

@tj
Copy link

tj commented Nov 25, 2011

oh hahhaha i just noticed you have describe('', function(){ and your assertions in there

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment