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

marionette-js-runner

v1.1.4

Published

Javascript ui testing framework built on top of mocha for testing webapps on gecko

Downloads

196

Readme

marionette-js-runner

Architecture diagram

This project is the sum of a number of other smaller more focused projects:

See MDN for more details about the intent of the project and where it's going.

Installing / Invoking tests

add marionette-js-runner and marionette-js-client to your project

npm install --save-dev marionette-client marionette-js-runner

Invoke a marionette-mocha test

# from the root of your project (where your package.json is)
./node_modules/.bin/marionette-mocha path/to/test.js

See ./node_modules/.bin/marionette-mocha --help for more docs on what it can do.

Like mocha there is support for an "opts" file which will be loaded with the specific configuration for your project.

The file must be called "marionette-mocha.opts" and live in one of the following locations:

  • test/
  • tests/
  • root of your project

Each location will be loaded if found. Any option that can be passed into marionette-mocha (see --help) can be placed in this file.

Exposed APIs for writing marionette tests

marionette (suite/describe like a api)

The marionette function is a wrapper around mocha's suite/describe blocks. They expose an additional field (a filter) which is an object which describes under which conditions a test may execute.

The filter is matched vs metadata from the particular host (like firefox / b2g-desktop ) the test is running on. Example host metadata

// this always runs
marionette('I always run', function() {
});

// only runs on firefox
marionette('firefox only', { host: 'firefox' }, function() {
  test('only executed when host is firefox');
});

// executed when firefox is the host OR b2g-desktop
marionette('b2g desktop or firefox', { host: ['firefox', 'b2g-desktop'] }, function() {

});

marionette.client (marionette client interface)

Creating a client is easy. Each test will run in a completely clean state ( with its own profile ). The default client has no profile options and is sync.

marionette('github.com', function() {
  var github = 'http://github.com';

  // no options are required by default.
  var client = marionette.client();

  setup(function() {
    client.goUrl(github);
  });

  test('logging into github', function() {
    // do stuff with the client
  });
})

Clients can be configured to have custom profiles. For instance, let's say you want to test a packaged app with specialized settings...

marionette('my custom app', function() {
  var client = marionette.client({
    profile: {
      // see for options https://github.com/mozilla-b2g/mozilla-profile-builder
      prefs: {
        // see about:config too
        'devtools.inspector.markupPreview': true
      },
      settings: {
        // turn off lockscreen
        "lockscreen.locked": false
      },

      // install a packaged app
      apps: {
        'domain-name-of-my-amazing-app.com': '/path/to/app'
      }
    }
  });

  // ... do stuff with your client
})

Clients have different "driver" types which determine how they connect with the marionette server. Typically you don't need to think about this, but it is important to note that the default driver is synchronous which means each marionette operation blocks (you can't really run servers in the same process).

marionette('be async man', function() {
  var client = marionette.client({
    driver: require('marionette-client').Drivers.Tcp
  });

  // imagine this is used to create an http server in this process
  var http = require('http');


  test('talk to the server in this process', function(done) {
    client.goUrl('http://localhost:port', function(err) {
      if (err) return done(err);

      // perform some other actions..
      done();
    });
  });
})

Multiple clients can also be created.

marionette('I like sending emails to myself', function() {
  var clientA = marionette.client();
  var clientB = marionette.client();

  // do something fancy like send an email from one client to another
});

marionette.plugin (plugin exposure/setup api)

One of the features of the client is extending its functionality without modifying the base code. For example if you wanted to extend the client to launch apps this can be done by exposing a new plugin.

// the particular case is based on: https://github.com/mozilla-b2g/marionette-apps

// expose something at the global level to all tests (you can do this from a helper file too)
marionette.plugin('apps', require('marionette-apps'));

marionette('my local test', function() {
  var client = marionette.client();
  var origin = 'app://calendar.gaiamobile.org';

  // this plugin only exists inside the current "marionette(function() { ... })" block
  marionette.plugin('myplugin', function(client) {
    return {
      doStuff: function() {}
    };
  });

  setup(function() {
    client.apps.launch(origin);
    client.apps.switchToApp(origin);
  });

  test('that calendar works', function() {
    // do some calendar testing inside of its frame
  });

  test('myplugin', function() {
    // leverage your custom plugin
    client.myplugin.doStuff();
  });
})