Overview
- wiremockのdocker-composeでの起動
- REST Client plugin for VSCode
Environment
- MacOS
- docker, docker-compose
wiremock
一番シンプルなmockの設定
{ "request": { "method": "GET", "url": "/items" }, "response": { "status": 200, "jsonBody": { "id": 1, "name": "item-name" }, "headers": { "Content-Type": "application/json" } } }
ディレイをつける、request bodyの一致の確認、外部ファイルの利用などは以下を参照。 https://github.com/yoshikipom/sandbox/tree/main/wiremock/dev/wiremock/mappings
docker-composeでの起動
--- version: '3' services: mockServer: image: wiremock/wiremock:latest-alpine volumes: - "./dev/wiremock/:/home/wiremock/" ports: - 9000:8080 restart: on-failure command: - --verbose - --disable-banner
run
docker-compose up
REST Client plugin for VSCode
インストール
https://marketplace.visualstudio.com/items?itemName=humao.rest-client
リクエスト
ファイルを準備
### GET http://localhost:9000/items ### POST http://localhost:9000/items Content-Type: application/json { "name": "name" }
Send Requestを押す