tj / should.js

BDD style assertions for node.js -- test framework agnostic
MIT License
2.75k stars 194 forks source link

should.not.exist(null) #132

Closed rhythmicdevil closed 11 years ago

rhythmicdevil commented 11 years ago

I am not quite sure what I am doing wrong here. I am getting an error saying that "Should" has no method "exist".

I have a callback that returns an error object or a null.

I am testing it with this:

should.not.exist(null)

I get the following error:

Uncaught TypeError: Object #<Object> has no method 'exist'

Here is the full test for reference:

   describe('AmbassadorMaster.createHadoopDrop()', function() {
       it('Should create directory structure for file drop', function(done) {
           App.createHadoopDrop(function(err){
               should.not.exist(null)
               console.log(err);
               done();
           });
       });
   });

Here is the method being tested:

AmbassadorMaster.prototype.createHadoopDrop = function(callback) {
    fs.stat(Config.outputs.hadoop.drop_dir, function(err, stats) {
        if (err || 'undefined' === typeof stats) {
            //TODO Split the path into a directory list
            fs.mkdir(Config.outputs.hadoop.drop_dir, function(err) {
                if (err) {
                    callback({
                        'log': 'exception',
                        'msg': 'Could not create Hadoop drop directory',
                        'path' : Config.outputs.hadoop.drop_dir,
                        'err': err
                    });
                } else {
                    callback(null);
                }
            });
        }
    });
};
btd commented 11 years ago

Which version of should.js do you use, and show rows where do you require it in test file.

rhythmicdevil commented 11 years ago

I assumed the latest version.

Section of package.json

    "devDependencies" : {
        "mocha" : "*",
        "should" : "*"
    },

Head of my test file:

require('should');
var fs = require('fs');
btd commented 11 years ago

If you just did require('should'); there is no should in scope. That is why it is undefined. You need var should = require('should');

rhythmicdevil commented 11 years ago

doh! Man I cant believe I let that get me by me. Thanks for the sanity check.

btd commented 11 years ago

No problem, sometimes need fresh look.