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

browserstack-workers

v0.2.5

Published

A library for creating workers on BrowserStack and retrieving results

Downloads

23

Readme

BrowserStack Runner

This is an abstraction layer built on top of the BrowserStack API to make it easier to run arbitrary jobs on BrowserStack workers. It is the basis for the BrowserStack testing framework that automatically runs your Jasmine or Mocha.js test suites on BrowserStack virtual machines. It can also be used to run other JavaScript tasks.

Installation

$ npm install browserstack-runner

Usage

var runner = require('browserstack-runner');

var client = runner.createClient('<username>', '<password>', '<api-key>');

client.createJob('<url>', function (err, job) {
  job.addBrowser({
    browser: 'chrome',
    browser_version: '27',
    os: 'OS X',
    os_version: 'Mountain Lion'
  });

  job.addBrowser(...);

  job.on('start', function (browser) {
    // The worker for `browser` has been queued or started
  });

  job.on('end', function (browser, data) {
    // The worker for `browser` has finished and returned `data`
  });

  job.on('complete', function () {
    // All workers have completed
  });

  job.on('error', function (browser) {
    // The worker for `browser` generated an error
  });

  job.run();
});

The createClient method creates a new instance of a BrowserStack client. As parameters it takes your BrowserStack username, password and api-key. The client only has a single method createJob.

The createJob takes as input a url, an optional options object and a callback. The URL is the "job" you want to run, and should be a HTML page on either a local or remote server. A secure tunnel to BrowserStack is automatically created. The options object currently only has a single value, timeout which should be the number of seconds a BrowserStack worker runs before being forcibly shut down. The callback is called with either an error object or a job instance.

The job instance has two public methods, addBrowser and run. The addBrowser method takes one or more browser specifications to create a BrowserStack worker for. The run method starts the runner and takes no parameters. The job instance is also an event emitter for the following events:

  • start: called when a worker has been created. The browser associated with the worker is passed as an argument.
  • end: called when a worker has finished. The browser associated with the worker, together with the result data is passed as an argument.
  • complete: called when all workers have terminated.
  • error: called when a worker error is detected. The browser associated with the worker is passed as an argument.

Writing jobs

A job should be a HTML page on either a local or remote server. The page can contain anything and the only requirement for returning data is that the page transmits its "data" as a POST message to the URL it originated from (in JavaScript this can be accessed as window.location.href. The data it returns must be JSON sent as application/json. Workers are shut down as soon as the runner receives the results.

License

BrowserStack Runner is licensed under the three-clause BSD license. Copyright 2013 Bram Stein, all rights reserved.