lapwinglabs / x-ray-phantom

phantom driver for x-ray.
111 stars 29 forks source link

Where is done and assert from? #13

Open alanjames1987 opened 8 years ago

alanjames1987 commented 8 years ago

In the documentation under "Usage" where is done and assert coming from?

var phantom = require('x-ray-phantom');
var Xray = require('x-ray');

var x = Xray()
  .driver(phantom());

x('http://google.com', 'title')(function(err, str) {
  if (err) return done(err); // <----------- where is this defined?
  assert.equal('Google', str); // <----------- where is this defined?
  done(); // <----------- where is this defined?
})

I assume they are coming from a user defined assertion library, but I feel like that should be made more clear.

Koleok commented 8 years ago

I think the implication is that this would live in a mocha/jasmine test, so this example would be much more clear as

var assert = require('assert');
var phantom = require('x-ray-phantom');
var Xray = require('x-ray');

var x = Xray().driver(phantom());

describe('this should work', () => {
  it('should get the title from google', done => {
    x('http://google.com', 'title')(function(err, str) {
      if (err) return done(err);

      assert.equal('Google', str);
      done();
    });
  });
});