8000 GitHub - zeachco/snapstub: Copy API endpoints to your fs and run a local server using them
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

zeachco/snapstub

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

snapstub NPM version Build Status

Heavily inspired by Jest Snapshot testing

Small command line tool that allows you to take "snapshots" of any given API endpoint and store the response. Using the start command will spawn a server that will serve all previously stored endpoints.

Install

npm install -g snapstub

Usage

Make sure you're in the desired folder to host your api mock files.

⬇️ Creates a new api stub:

snapstub add http://example.com/api/foo/bar

...create as many snapshots as you want.

🚀 Starts your mock server:

snapstub start

✨ Your endpoint will be locally available at: http://localhost:8059/api/foo/bar

More options

If you want to save one or many different http methods, use the --method flag:

snapstub add http://example.com/api/foo/bar --method=get,post,put

Using custom port and/or folder name:

export SNAPSTUB_FOLDER_NAME=my-mock-folder/
export SNAPSTUB_PORT=9000
snatstub start

More info

By default snapshots will be saved in a __mocks__ folder that resolves from the current working directory, so make sure you run the commands from the correct project folder you desire.

NOTE: v1.0.x only supports json endpoints.

Credit

snapstub wouldn't be possible without stubborn-server, go take a look at it if you need to support more complex scenarios.

License

MIT © Ruy Adorno

About

Copy API endpoints to your fs and run a local server using them

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%
0