1

How to test function which fetch file from remote server with Buster ? I wrote test like

buster.testCase("Remote fetch file", {
    "test it": function () {
        assert(true);
    },

    "remote fetch file" : function (){
        remoteFileFetchingFunction(credentials, 'whoami', function (err, result) {
            assert.equals(result, 'John');
        });
    }

});

But always get error like Failure: No assertions!

PaolaJ.
  • 10,872
  • 22
  • 73
  • 111

1 Answers1

1

You have to make an asynchronous test do to this. To tag a test as asynchronous, you need to make the test function take one argument. By convention, this argument should be called done. Call the argument to tell buster the test has finished running. That's all there is to it :)

"my test": function (done) {
    doAsyncThing(function (arg) {
        assert.equals(arg, 123);
        done();
    });
}

// Alternative syntax
"my test": function (done) {
    doAsyncThing(done(function (arg) {
        assert.equals(arg, 123);
    }));
}

The advantage of using the alternative syntax is that if your callback function throws an error, "done" will still be called.

August Lilleaas
  • 54,010
  • 13
  • 102
  • 111