@tiandatong/anymock
v1.5.0
Published
mock service base on Anyproxy.
Downloads
1
Maintainers
Readme
mock service base on Anyproxy.
English | 简体中文
Features
- support https
- support jsonp and JSON API
- support resources replace(js\css etc.)
Some principle of this project:
- Unix philosophy: Do One Thing and Do It Well
- form follows function
Getting Started
Installation
npm install @tiandatong/anymock -g
Usage
run command below anywhere
λ anymock init
[AnyProxy Log][2018-11-15 12:35:52]: throttle :10000kb/s
[AnyProxy Log][2018-11-15 12:35:52]: clearing cache file...
[AnyProxy Log][2018-11-15 12:35:52]: ==>>> clearing cache
[AnyProxy Log][2018-11-15 12:35:52]: closing webserver...
[AnyProxy Log][2018-11-15 12:35:52]: Http proxy started on port 8001
[AnyProxy Log][2018-11-15 12:35:52]: Active rule is: a rule to hack response
first run with 'init' will create a directory 'mock' contains *.config.json and mocks.json template(default api.config.json and file.config.json), and generate root cert
trust the root cert
configure chrome's proxy to http://127.0.0.1:8001 via Proxy SwitchyOmega
then you can browse
https://api.github.com/repos/temberature/anymock/branches?protected=0
https://suggest.taobao.com/sug?code=utf-8&callback=KISSY.Suggest.callback&q=apple
https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js
and see the corresponding mock result
[{
"name": "master1",
"commit": {
"sha": "51a0a39acfb1d029345e896cca6a6a2c3625816b",
"url": "https://api.github.com/repos/temberature/anymock/commits/51a0a39acfb1d029345e896cca6a6a2c3625816b"
}
}]
KISSY.Suggest.callback(
{
"result": [
[
"apple watch4",
"14770"
],
[
"apple pencil",
"12500"
]
],
"shop": "apple",
"tmall": "apple"
}
)
//uncompressed jquery
Running the tests
Explain how to run the automated tests for this system
Break down into end to end tests
Explain what these tests test and why
npm test
Development
git clone https://github.com/temberature/anymock.git
cd anymock
npm install
npm start
Built With
Contributing
Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.
Versioning
We use SemVer for versioning. For the versions available, see the tags on this repository.
License
This project is licensed under the MIT License - see the LICENSE.md file for details