This one is frustratingly puzzling.
I have the following test fixture:
describe('#post', function(){
var options,
bodyContent,
bodyWriter;
beforeEach(function(){
// setup common objects ...
});
it('should have request body', function(done){
httpHelper.post(options, bodyWriter, function(err, data){
should.not.exist(err);
should.exist(requestData.body);
requestData.body.should.eql(bodyContent);
done();
});
});
// ...
});
Now, this works just fine - right up until the point where I add another test:
it('should contain path from options arg', function(done){
httpHelper(options, bodyWriter, function(err, data){
should.not.exist(err);
requestData.options.path.should.eql(options.path);
done();
});
});
Now when I run the fixture, I get the following:
http
#post
✓ should require options
✓ should have body
1) should have body
✓ should contain path from options arg
I have no idea why this test is being run twice. Any thoughts?
done
that is provided in theshould have body
(orshould have request body
???) test is called twice, the test would appear to run twice. If the callback that you pass tohttpHelper
is registered somewhere and this registration persists between tests, then when your second test executes, the callbacks in the first and second test would be executed.