function bootstrapDiagram(options, locals) {

  return function() {

    var testContainer;

    // Make sure the test container is an optional dependency and we fall back
    // to an empty <div> if it does not exist.
    //
    // This is needed if other libraries rely on this helper for testing
    // while not adding the mocha-test-container-support as a dependency.
    try {
      testContainer = TestContainer.get(this);
    } catch (e) {
      testContainer = document.createElement('div');
      testContainer.classList.add('test-content-container');

      document.body.appendChild(testContainer);
    }

    var _options = options,
        _locals = locals;

    if (!_locals && isFunction(_options)) {
      _locals = _options;
      _options = null;
    }

    if (isFunction(_options)) {
      _options = _options();
    }

    if (isFunction(_locals)) {
      _locals = _locals();
    }

    _options = merge({
      canvas: {
        container: testContainer,
        deferUpdate: false
      }
    }, OPTIONS, _options);


    var mockModule = {};

    forEach(_locals, function(v, k) {
      mockModule[k] = [ 'value', v ];
    });

    _options.modules = [].concat(_options.modules || [], [ mockModule ]);

    // remove previous instance
    cleanup();

    DIAGRAM_JS = new Diagram(_options);
  };
}
Bootstrap the diagram given the specified options and a number of locals (i.e. services)

@example

```javascript
describe(function() {

  var mockEvents;

  beforeEach(bootstrapDiagram(function() {
    mockEvents = new Events();

    return {
      events: mockEvents
    };
  }));

});
```

@param {Object} (options) optional options to be passed to the diagram upon instantiation
@param {Object|Function} locals  the local overrides to be used by the diagram or a function that produces them
@return {Function}         a function to be passed to beforeEach