npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

spook

v0.8.2

Published

functional testing harness for casperjs

Downloads

103

Readme

spook Spook

functional testing harness using casperjs.

Install

Tests are run via casperjs on phantomjs and slimerjs

[sudo] npm -g install spook

Global deps:

[sudo] npm -g install [email protected] casperjs phantomjs
# see https://github.com/laurentj/slimerjs/issues/301

If you want to run the spook server and generate thumbnails for screenshots, also install graphicsmagick. You can do this on osx via Homebrew

brew install graphicsmagick

Screenshots of spook server

configured jobs

job runs

raw run output

run results

formatted log output

screenshot thumbnails

Why Spook?

  • parallel execution of casperjs tests
  • automatic inclusion of include files (extending this approach)
  • optional recording of results with server interface to run tests and browse results

Running tests via Spook

A typical spook command (run from the root of this cloned repo) might look like this:

spook --out run --tests '{homepage,loads/{bundle,catalog}.js}' --base tests/www --includes 'includes/{common,www}/*.js' -- --env=production --verbose --engine=slimerjs

Let's break that down:

  • spook the spook executable
  • --out the relative directory to output any screenshots
  • --tests a glob pattern of what tests to run, this pattern should be in quotes to prevent shell variable expansion
  • --includes a glob pattern of what files to invlude before tests are run, this pattern should be in quotes to prevent shell variable expansion
  • --base a local directory path to where the actual tests are (makes --test simpler to write and removes this path prefix from results)
  • -- signifies the end of arguments/options sent to spook, all values after this are sent to casperjs directly
  • --env=production passing an option called env to casperjs cli
  • --verbose putting casperjs into verbose mode (recommended)
  • --engine=slimerjs telling casperjs to run tests in gecko/firefox.

By default on the command line spook runs tests in series. You can have it run tests in parallel using:

--work parallel

Note that stdout will have multiple test output at the same time, but spook will show a summary at the end. By default spook runs 3 tests at once. You can up this limit with

--parallel-limit 5

Spook server

To save a test job and be able to run it from the web interface, add `--add 'name of job' to the command:

spook --add 'example job' --out run --tests '{homepage,loads/{bundle,catalog}.js}' --base tests/www --includes 'includes/{common,www}/*.js' -- --env=production --verbose --engine=slimerjs

You can then start a spook server to run/view tests, via

spook --server

Saving screenshots

To have spook automatically parse screen shots and save assets to the right location, add this function to one of your include files (spook parses logout for the string "saving screenshot"). We're overriding the default casper.capture, but you could create a new function. You then create a screenshot with casper.capture('name-without-extension'). Spook populates the casper.cli.options.output value based on the --out argument passed to it.

casper._capture = casper.capture;
casper.capture = function capture(targetFilepath, clipRect, opts) {
  opts = opts || {};
  opts.format = opts.format || 'jpg';
  opts.quality = opts.quality || 75;
  console.log('saving screenshot ' + targetFilepath + '.' + opts.format);
  casper._capture(casper.cli.options.output + '/' + targetFilepath + '.' + opts.format, clipRect, opts);
};

Reloading spook pages

Spook uses socket.io to send progress of runs to the browser. The list of run jobs don't have any automatic refreshing built in yet, but you can pass ?refresh=X where X is a number in seconds which will make spook reload any page via a meta tag.


Spook logos designed by Julien Deveaux from the Noun Project :: Creative Commons – Attribution (CC BY 3.0)