Skip to content

Commit

Permalink
Fix broken mock, added mock documentation for variants
Browse files Browse the repository at this point in the history
  • Loading branch information
RoanPaulus committed Dec 12, 2024
1 parent 63489fe commit a1585aa
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
17 changes: 17 additions & 0 deletions mocks/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
# Usage

## Variant switching

[Official Documentation](https://www.mocks-server.org/docs/usage/variants/)

It can be handy to switch datasets for testing.
For example, when you need to see what happens when an api would give no data, but another one does.

To use different data sets.
You can select a variant or collection with the arrow keys in the mock server menu or
permanently in the `mocks.config.js` file.

When adding a new variant try to group them under a name already present.
So we don't end up with variants called `void`, `no-data` and `nothing` for the same thing.
You can check what is already there in `collections.json` or in the menu.

# Adding a router

1. Add your endpoint in `/routes`. See example 1 below:
Expand Down
2 changes: 1 addition & 1 deletion mocks/routes/parkeren.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ const NO_DATA_VARIANT = {
id: 'no-data',
type: 'json',
options: {
status: 200,
body: {
result: 'success',
count: 0,
status: 200,
data: [],
},
},
Expand Down

0 comments on commit a1585aa

Please sign in to comment.