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

lightfoot

v1.6.1

Published

Run your own tests in a real browser with selenium then stream the results out.

Downloads

13

Readme

lightfoot

Run your own tests in a real browser with selenium then stream the results out. Uses leadfoot under the hood.

NPM

install

npm install lightfoot --save-dev

usage

Install and run a Selenium Server.

Add a test target to your scripts of your package.json:

{
  "name": "myapp",
  "version": "0.1.0",
  "scripts": {
    "test": "lightfoot --url=http://localhost:3000/test.html"
  },
  "devDependencies": {
    "lightfoot": "^1.0.0"
  }
}

Then run the command npm test to run your test URL in a real browser via selenium.

notifying lightfoot

Your test suite can communicate with lightfoot using a global variable stack: window.NOTIFY_LIGHTFOOT

When your tests are done, push an object to the stack:

window.NOTIFY_LIGHTFOOT.push({ type: 'done', passed: 2, failed: 1 })

An example adapter if you're using QUnit:

window.NOTIFY_LIGHTFOOT = []
function notifyLightfoot(type, payload) {
  payload.type = type
  window.NOTIFY_LIGHTFOOT.push(payload)
}
QUnit.begin(function(data) { notifyLightfoot('begin', data) })
QUnit.done(function(data) { notifyLightfoot('done', data) })
QUnit.testDone(function(data) { notifyLightfoot('testDone', data) })
QUnit.log(function(data) { notifyLightfoot('assertion', data) })

and now lightfoot will know and report more info about the lifecycle of your test suite.

api usage

// Create an instance of lightfoot
var lightfoot = require('lightfoot')({
  url: 'http://localhost:3000/test.html',
  browserName: 'firefox',
  varName: 'window.NOTIFY_LIGHTFOOT',
})

// Open a session and run the tests
lightfoot.run(function(code) {
  process.exit(code || 0)
})

// Pipe to built in tap reporter or your own reporter
lightfoot.pipe(require('lightfoot/reporters/tap')()).pipe(process.stdout)

running multiple sessions concurrently

There is a built in helper to run mutliple sessions concurrently:

var runAll = require('lightfoot').runAll
// Run each of these sessions with 2 at a time concurrently
runAll([
  { url: 'http://localhost:3000/test.html?module=one.js', browserName: 'chrome' },
  { url: 'http://localhost:3000/test.html?module=two.js', browserName: 'chrome' },
  { url: 'http://localhost:3000/test.html?module=one.js', browserName: 'firefox' },
  { url: 'http://localhost:3000/test.html?module=two.js', browserName: 'firefox' },
], 2, function(codes) {
  // Exit with the greatest exit code
  process.exit(codes.reduce(function(code, last) {
    return (code > last) ? code : last;
  }, 0))
})

using with sauce labs

Install and run Sauce Connect

Specify the Sauce Labs Selenium web driver URL with your username and access key:

require('lightfoot')({
  url: 'http://localhost:3000/test.html',
  seleniumUrl: 'http://username:[email protected]:80/wd/hub',
}).run(function(code) {
  process.exit(code || 0)
})

Now through all kinds of mad science, your tests served locally are ran in a real browser at Sauce Labs and reported to your terminal.

Release History

  • 1.6.1 - Fix for running a single test runner.
  • 1.6.0 - Add pollInterval option to delay how often we poll the console.
  • 1.5.0 - Rename log event to assertion. log is now used to track console.log messages in the browser.
  • 1.4.0 - Ability to specify capabilities. Helper for running multiple sessions concurrently. Pipe errors to reporter when they occur.
  • 1.3.1 - Add repository field to package.json. Ensure assertions on pretty reporter go on their own line.
  • 1.3.0 - Add pretty reporter
  • 1.2.1 - Avoid multiple done() calls on finish
  • 1.2.0 - Do not call quit() automatically any more to allow for async clean up. User must call quit()
  • 1.1.1 - Ensure quit is called before runCallback
  • 1.1.0 - Fixes to prevent runner from hanging. id is no longer required. Fixes to tap reporter. session and sessionId is exposed. quit is called upon the end automatically now.
  • 1.0.0 - Initial release

License

Copyright (c) 2014 YouNeedABudget.com Licensed under the MIT license.