WireMock and Node.js

WARNING: This document is for an old WireMock 2.x baseline. See the documentation for the current WireMock 3.x baseline here

Disclaimer: This solution page includes resources maintained by their authors outside the WireMock organization on GitHub. The info is provided as is without guarantees unless explicitly specified. Referenced projects and guidelines might be incompatible with the recent WireMock 3.x releases or the recent versions of the target technology or framework.

Please use with caution, and submit GitHub issues or pull requests to this page and referenced repositories if something is missing, broken or needs update.

WireMock Captain #

WireMock Captain provides an easy interface for testing HTTP-based APIs. Tests are implemented in TypeScript or JavaScript with the Node.js runtime. Mocking is performed by WireMock, which typically runs in a Docker container. Note that this library is maintained outside the WireMock organization on GitHub.


import { WireMock } from 'wiremock-captain';

describe('Integration with WireMock', () => {
  // Connect to WireMock
  const wiremockEndpoint = 'http://localhost:8080';
  const mock = new WireMock(wiremockEndpoint);

  test('mocks downstream service', async () => {
    const request: IWireMockRequest = {
      method: 'POST',
      endpoint: '/test-endpoint',
      body: {
        hello: 'world',
    const mockedResponse: IWireMockResponse = {
      status: 200,
      body: { goodbye: 'world' },
    await mock.register(request, mockedResponse);

    // rest of the test

WireMock REST Client #

The WireMock REST client is a lightweight module to interact with a running WireMock server based on its OpenAPI 3.0 spec via REST API. Note that this library is maintained outside the WireMock organization on GitHub.

import { WireMockRestClient } from 'wiremock-rest-client';

const wireMock = new WireMockRestClient('http://localhost:8080');
const stubMappings = await wireMock.mappings.getAllMappings();

await wireMock.global.shutdown();