Skip to content

Instantly share code, notes, and snippets.

@MattMcFarland
Created November 14, 2015 10:27
Show Gist options
  • Select an option

  • Save MattMcFarland/ea72a43eb3edb64f6b2f to your computer and use it in GitHub Desktop.

Select an option

Save MattMcFarland/ea72a43eb3edb64f6b2f to your computer and use it in GitHub Desktop.
BDD - Use with Mocha, Chai, and Selenium
// Start with a webdriver instance:
var
baseUrl = 'localhost:8080',
chai = require('chai'),
assert = chai.assert,
expect = chai.expect,
should = chai.should(),
chaiWebdriver = require('chai-webdriver'),
request = require('supertest')(baseUrl),
sw = require('selenium-webdriver'),
driver = new sw.Builder()
.withCapabilities(sw.Capabilities.phantomjs())
.build();
chai.use(chaiWebdriver(driver));
driver.get(baseUrl);
describe('Connectivity\n ---------------', () => {
it('connects to localhost', (done) => {
request.get('/')
.end((err, res) => {
should.exist(res, 'failure to connect to ' + baseUrl);
done();
})
})
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment