dalekjs/dalek — pull request #51 by stuartlangridge (2014-01-28 14:20:25+00:00)
Title: Allow passing a JS test object rather than a filename of tests

When using dalek from JS rather than from the command line, it is useful to be able to pass an object of tests rather than the filename of a file which contains tests.

Example (which works with provided patch) and is the only file required (no extra file containing tests needed):

var Dalek = require("dalekjs");

var tests1 = [{
'Page title is correct': function (test) {
test
.open('http://google.com')
.assert.title().is('Google', 'It has title')
.done();
}
}];

var dalek = new Dalek({
tests: tests1, browser: ["chrome"],
driver: [], reporter: [], viewport: {}, logLevel: 5,
noColors: true, noSymbols: false, remote: null
});

dalek.run();
var Dalek = require("dalekjs");

var tests1 = [{
'Page title is correct': function (test) {
test
.open('http://google.com')
.assert.title().is('Google', 'It has title')
.done();
}
},{
'Page title is correct, 2': function (test) {
test
.open('http://dalekjs.com')
.assert.title().is(
'DalekJS - Automated cross browser testing with JavaScript',
'It has title')
.done();
}
}];

var dalek = new Dalek({
tests: tests1, browser: ["chrome"],
driver: [], reporter: [], viewport: {}, logLevel: 5,
noColors: true, noSymbols: false, remote: null
});

dalek.run();