Search code examples
node.jstestingbuster.js

Test a webservice response with Buster.js


I am maintain a search server written in node.js www.foragejs.net and I am trying to put together a test suite, that checks that responses are correctly formatted.

How would I do this using buster.js?


Solution

  •   "test asynchronous": function (done) {
        var options = {
          host: 'localhost',
          port: 3000,
          path: '/search?q=moscow'
        };
        http.get(options, done(function(res) {
          console.log("Got response: " + res.statusCode);
          assert.equals(res.statusCode, 200);
        })).on('error', done(function(e) {
          console.log("Got error: " + e.message);
          assert(false);
        }));
      }