node package manager


Mock for Docker


A mock for Docker!

Require it from your node program:

var dockerMock = require('docker-mock');

You can also use the command line interface, just run docker-mock after installing the package globally.

See the tests for some sample usage, but you should be able to point your docker client at this mock and test against it.

This does have support for simulating failures during build. This is done (using dockerode) by doing the following:

// file is a tar containing at minimum a Dockerfile 
var file = ...;
    t: 'doomedImage',
    fail: true
  function (err, res) {
    // err will not be null 

If you want to disable randomly generated events exposed under /events endpoint please use ENV var: DISABLE_RANDOM_EVENTS=true.

You can manually emit docker mock events.

  var dockerMock = require('docker-mock');
  dockerMock.listen(5354);'data', JSON.stringify({ status: 'die', from: '..', id: '...', time: '...' }));
  // or'data',;

Please make sure all unit tests pass, lint passes, and coverage remains high during development (see below for details).

Testing is done locally via npm test.

Coverage is now run by Lab via npm test. Output at the bottom shows percent coverage verses a threshold set in package.json.