Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Drive CasperJS from Node.js
JavaScript
branch: master

This branch is 1 commit ahead, 47 commits behind SpookyJS:master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
examples
lib
tests
.gitignore
LICENSE
Makefile
README.md
package.json

README.md

SpookyJS

Drive CasperJS from Node.js.

Installation

Prerequisites

SpookyJS is available from npm.

$ npm install spooky

Usage

var Spooky = require('../lib/spooky');

var spooky = new Spooky({
        child: {
            script: './lib/bootstrap.js',
            spooky_lib: './node_modules'
        },
        casper: {
            logLevel: 'debug',
            verbose: true
        }
    }, function (err) {
        if (err) {
            e = new Error('Failed to initialize SpookyJS');
            e.details = err;
            throw e;
        }

        spooky.on('error', function (e) {
            console.error(e);
        });

        /*
        // Uncomment this block to see all of the things Casper has to say.
        // There are a lot.
        // He has opinions.
        spooky.on('console', function (line) {
            console.log(line);
        });
        */

        spooky.on('log', function (log) {
            if (log.space === 'remote') {
                console.log(log.message.replace(/ \- .*/, ''));
            }
        });

        spooky.start(
            'http://en.wikipedia.org/wiki/Spooky_the_Tuff_Little_Ghost');
        spooky.thenEvaluate(function () {
            console.log('Hello, from', document.title);
        });
        spooky.run();
    });

A minimal example can be found in the repo under examples. Run it like this:

$ node examples/hello.js

A small example Cucumber.js test suite can be found in the repo under examples/cucumber. To run the suite:

$ make cucumber.js

You may change the port that the fixture server runs on by setting the TEST_PORT make parameter.

See the tests for an example of how to use SpookyJS with Mocha.

Development

Running the tests

SpookyJS includes a suite of unit tests, driven by Mocha. To run the tests:

$ make test

The following make parameters are supported (defaults are in parentheses):

  • TEST_REPORTER the Mocha reporter to use (dot)
  • TEST_PORT the port to run the fixture web server on (8080)
  • TEST_TIMEOUT threshold in ms to timeout a test (4000)
  • TEST_SLOW threshold in ms to say a test is slow (2000)
  • TEST_ARGS Additional arguments to pass through to Mocha
  • TEST_DEBUG Print debug logging to the console (false)
  • TEST_TRANSPORT the Spooky transport to use when running the tests (stdio)

License

SpookyJS is made available under the MIT License.

Acknowledgements and Attribution

The image tests/fixtures/fail-road.jpeg is the work Fail Road and is copyright (c) 2007 fireflythegreat and made available under an Attribution 2.0 Generic license.

Something went wrong with that request. Please try again.