node package manager
Love JavaScript? Your insights can make it even better. Take the 2017 JavaScript Ecosystem Survey »



A simple node package that lets you manage your Mountebank test server.


go get ""
import(mb "")



Install Mountebank:

npm install -g mountebank --production

Start Mountebank:


I recommend reading the Mountebank documentation for a deeper understanding of their API.

Create Imposter

imp := mb.NewImposter().WithPort(1974)WithStub(stb)
err := imp.Create()

Create a Stub

stb := mb.NewStub()

Create a new Predicate

        WithHeader("Content-Type", "application/json").
        WithHeader("Authorization", "bearer xxx")

Create a new Response

    emp := &Employee{}
        WithHeader("Conent-Type", "application/text"))

Create a new Response with a wait behavior

    emp := &Employee{}
        WithHeader("Conent-Type", "application/text"))

Using mountebank in go tests

check if mountebank is running in TestMain

    func TestMain(m *testing.M) {
        if !mb.IsRunning() {
            panic(fmt.Errorf("Mountebank is not running; see for installation instructions"))

add a configuration

    imp, err := mb.NewImposter().WithStub(mb.NewStub().WithResponse(mb.NewResponse().WithBody(b))).Create()
    assert.Nil(t, err)

this returns an imposter with a randomly assinged port number;

client := authentication.New(config.NewConfig().WithEndpoint(fmt.Sprintf("http://localhost:%v", imp.Port)))

create a default imposter

    emp := &Employee{}
    imp, err := mb.DefaultPostImposter("/item", emp, http.StatusCreated)