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


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.

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.

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() {

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('', function() {
  var github = '';
  // no options are required by default. 
  var client = marionette.client();
  setup(function() {
  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 
      prefs: {
        // see about:config too 
        'devtools.inspector.markupPreview': true
      settings: {
        // turn off lockscreen 
        "lockscreen.locked": false
      // install a packaged app 
      apps: {
        '': '/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.. 

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 

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: 
// 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://';
  // this plugin only exists inside the current "marionette(function() { ... })" block 
  marionette.plugin('myplugin', function(client) {
    return {
      doStufffunction() {}
  setup(function() {
  test('that calendar works', function() {
    // do some calendar testing inside of its frame 
  test('myplugin', function() {
    // leverage your custom plugin