Skip to content

williamhaw/setup-wiremock-action

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Repository files navigation

setup-wiremock-action

Sets up a Wiremock API using the provided stubs.

Requirements: Java (preferably Java 11)

Inputs

mappings

Required Path to folder with JSON stubs.

References:

files

Required Path to folder with static files. Use these files in the mappings to fill out the response body.

References:

command

Required Command to run tests

Note: a child process is spawned and run in a shell with this command, so do not run unvalidated commands.

Example: 'npm test --testNamePattern=MyApiTests'

http-port

Port on which to run Wiremock. Defaults to 8080.

verbose

Turns on verbose Wiremock logging (log all requests and responses). Defaults to false (only log stub mismatches).

Outputs

wiremock-stdout

Logs from Wiremock. If any stubs are not matched, they will be reported here.

Example usage

Basic usage

on: [push]

jobs:
  test:
    runs-on: ubuntu-latest
    name: Set up WireMock as a standalone process
    steps:
      - name: Checkout
        uses: actions/checkout@v3
      - name: Setup Java
        uses: actions/setup-java@v3
        with:
          distribution: 'temurin'
          java-version: '11'
      - name: Action E2E Test
        uses: williamhaw/setup-wiremock-action@v0.1.2
        id: setup-wiremock
        with:
          http-port: '8080'
          mappings: 'example-mapping-directory'
          files: 'example-files-directory'
          command: 'node example.test.js'
          verbose: false
      - name: Get the WireMock standard output
        run: echo "${{ steps.setup-wiremock.outputs.wiremock-stdout }}"