node package manager


Pure-Javascript Demo Recorder and Integration Testing Suite


As seen on YouTube.

Inspired by Selenium, Capybara, Zombie.js, Jasmine, Mocha, Chai and Syn.js.


npm install choreography

Using the Recorder

# symlink the static html+js assets to a public-facing
# subdirectory within your application
ln -s node_modules/choreography public/test
# then browse to the demo recorder
# replace /debug/slides with the actual url of your app you want to test
# note that it must be on the same domain and port for security reasons
google-chrome http://localhost:3000/test/recorder.html#/debug/slides

Using the Integration Tester

Make a view like this (haml example):

- content_for :head do
  = stylesheet_link_tag "test/suite", :media => 'all'
  = javascript_include_tag "test/suite"
= javascript_include_tag "test/specs"

The test/suite stylesheet just includes the mocha styles (example in scss+sprockets)

//= require node_modules/choreography/node_modules/mocha/mocha

The test/suite javascript looks like this (coffee+sprockets):

#= require node_modules/choreography/node_modules/mocha/mocha 
#= require node_modules/choreography/node_modules/chai/chai 
#= require node_modules/choreography/node_modules/async2/coffee/async2 
#= require node_modules/choreography/vendor/syn 
#= require_self 
  ui: 'bdd'
  timeout: 1000*60*5 # 5 min 
  globals: [

The test/specs javascript looks like this (coffee+sprockets):

#= require node_modules/choreography/coffee/actor 
#= require node_modules/choreography/coffee/browser 
#= require_tree ./mock/ 
#= require_tree ./unit/ 
#= require_tree ./integration/ 
#= require_self

Where the ./integration/ folder contains a bunch of *_spec.js files which get aggregated together by those sprockets directives into that single specs.js file.

Inside each spec is a mocha test which looks like this (in coffee);

assert = chai.assert
window.frame = undefined
describe 'Slides'->
  beforeEach (done) ->
      '<iframe name="iframe-fixtures" name="fixtures" style="width:98%;height:50%;position:fixed;left:1%;bottom:0;border:none;border-top:3px double #333"/>')
        window.frame = window.frames['iframe-fixtures']
    it 'can complete blue slider sliide'(done) ->
      (new actor)
        .read('h2#slide-title''Are you listening?')

Where /debug/slides again is the url you want to test in the iframe.

Of course, that's a lot of setup. Will improve with time.

Useful documentation

Syn.js API Reference

Syn is the library that powers the click, drag, keystroke recording and playback.

Zombie.js Browser API Reference

Our Browser class sort of resembles the one from zombie.js.