whistle.mockya

0.4.2 • Public • Published

whistle.mockya

A rule-based API Data Mock plugin built on whistle.

Usage

Install & Start whistle

npm i -g whistle
w2 start

Install whistle.mockya

w2 install whistle.mockya

Proxy your website

Use tools like SwitchyOmega to proxy your website to whistle

Add rule in whistle's Rules tab

[your_api_prefix] mockya://[mockya_collection_id]

# for example
http://mockya.test/api mockya://test

image

Open whistle.mockya to add mock data

Visit http://localhost:8899/whistle.mockya (replace port with your own one) and install as PWA (recommended)

image

Features

Group your mock data in collections

image

Match request by url path & key-value pair in query/body

image

Auto switch mock data based on rules

Kapture 2024-03-18 at 20 17 42

Support JSON5 & JavaScript & Mock.js

You can compose your mock data in both JSON5 and JavaScript, along with Mock.js syntax.

image

image

Customize response delay

Useful when you need to test things like loading state UI.

Kapture 2024-03-18 at 20 32 38

Encode your data on demand

MockYa has special 'command' syntax to encode specific value in json.

// append '>[command]' to some field
{ "key>[command]": xxx }

// for example
{ "data>encode": { "a": 1 } }

// will return
{ "data": "{\"a\":1}" }

Kapture 2024-03-18 at 20 41 53

Currently support:

Command Description
encode use JSON.stringify to encode field value

Readme

Keywords

Package Sidebar

Install

npm i whistle.mockya

Weekly Downloads

0

Version

0.4.2

License

none

Unpacked Size

3.88 MB

Total Files

96

Last publish

Collaborators

  • mapoos