Serve your first mock
Make GET /users/123 return Ada. Once you see the response, add a second outcome and switch to it while the server is running.
Install the CLI
For a project install, run the command in the directory containing your package manifest. In an empty directory, run npm init -y first. You will also need a POSIX shell and curl.
Define the user response
Create a folder for your mock files.
Save the following Route as mocks/routes/users.yaml. It handles GET /users/{id}. The user-123 Case picks requests for ID 123, and its success Behavior returns Ada.
Create a Collection named happy-path so Decoy starts with the success response.
Request the user
Run the server from the directory containing mocks/. Leave this terminal open. The --watch flag lets you edit the files in the next step.
If you installed the standalone binary, run the same command starting at decoy serve.
In a second terminal, request the user.
Look for 200 OK and this response body:
Switch to a 404
Replace the Route file with this version. It adds a second Behavior named missing beside success.
Append a second Collection to mocks/collections.yaml. Its Behavior address ends in missing, so the same request now has a different response available.
After Decoy reloads the files, switch Collections from the second terminal.
Repeat the original request. This time you'll see 404 Not Found and the body not found.
Try a path you haven't mocked:
Look for 501 Not Implemented and x-mock-miss: true. Decoy tells you what failed to match instead of forwarding the request to a real service. See How mock misses work.
Stop Decoy with Ctrl-C in the server terminal.
To keep these settings in your project, put the flags in decoy.yaml. To match another user, add a Case. To switch this response from a browser test, follow the Playwright or Testplane setup.