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

choreography

v0.1.1

Published

Pure-Javascript Demo Recorder and Integration Testing Suite

Downloads

7

Readme

Choreography

As seen on YouTube.

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

Installation

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"

#mocha

= 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

mocha.setup
  ui: 'bdd'
  timeout: 1000*60*5 # 5 min
  globals: [
    'csrf_token'
    'csrf_param'
    'frame'
    'move'
    '__synthTest'
    '__screenCapturePageContext__'
  ]

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

mocha.run()

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) ->
    jQuery('iframe[name=iframe-fixtures]').remove()
    jQuery('body').append(jQuery(
      '<iframe name="iframe-fixtures" name="fixtures" style="width:98%;height:50%;position:fixed;left:1%;bottom:0;border:none;border-top:3px double #333"/>')
      .load(->
        window.frame = window.frames['iframe-fixtures']
        done()
      )
      .attr('src', '/debug/slides')
    ).css('padding-bottom', jQuery('iframe[name=iframe-fixtures]').height()+20+'px')

    it 'can complete blue slider sliide', (done) ->
      (new actor)
        .select('#slides', 'modules/01/_11e')
        .read('h2#slide-title', 'Are you listening?')
        .within(20000).drag('div.handle-blue:eq(0)', '724X143')
        .within(10000).drag('div.handle-blue:eq(1)', '731X220')
        .within(10000).drag('div.handle-blue:eq(2)', '616X328')
        .within(20000).click('button.button-green-ok')
        .finally(done)

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.

Credits