Skip to content

Instantly share code, notes, and snippets.

@asciidisco
Created May 29, 2014 10:17
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save asciidisco/37c35d511213228d3da7 to your computer and use it in GitHub Desktop.
Save asciidisco/37c35d511213228d3da7 to your computer and use it in GitHub Desktop.
// how to install/first steps http://dalekjs.com/pages/getStarted.html#install
// how to use it within grunt: https://www.npmjs.org/package/grunt-dalek
module.exports = {
'Can access the DOM': function (test) {
test.open('http://dalekjs.com/')
// the execute method executes JavaScript within a browser & also has
// full access to the DOM
.execute(function (message) {
// the "data" method is a simple wrapper around a key/value store
// that also can handle complex JSON objects (or serialized DOM objects)
this.data('fromBrowser', window.location.href + message);
}, '::I am a string') // more arguments can be appended to the function
// as dalek has no(t yet a) "execute that in node" function,
// we "abuse" the log function to execute & work with data from the browser
.log.info(function () {
// This is entirely NODEJS, here can be done anything
// filesystem access, process mgmt. ect.
// logs: "http://dalekjs.com::I am a string"
console.log(test.data('fromBrowser'));
// if you want to reuse that information later in another grunt task,
// I would suggest to use a store like this: https://github.com/felixge/node-dirty
})
.done();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment