capture = function(fileName) {
  // Return the async function.
  return function(done) {

    // The directory to store the screenshots.
    var dir = __dirname + '/../screenshots';

    // Check that the directory exists.
    fs.exists(dir, function(exists) {
      if (exists) {
        $.capture(dir + '/' + fileName + '.png', done);
      }
      else {
        fs.mkdir(dir, function(err) {
          if (err) return done(err);
          $.capture(dir + '/' + fileName + '.png', done);
        });
      }
    });
  }
}
Method to capture and ensure the screenshots directory exists.