• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

chinesedfan/parrot-mocker-web: Simple web server to forward received requests to ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称:

chinesedfan/parrot-mocker-web

开源软件地址:

https://github.com/chinesedfan/parrot-mocker-web

开源编程语言:

JavaScript 76.1%

开源软件介绍:

parrot-mocker-web npm version Build Status Coverage Status License

中文文档

This project provides a simple mock server, which works with the Chrome plugin parrot-mocker.

Support:

  • foward requests of pages(xhr/jsonp/fetch) to the real web server, or just mock
  • list all forwarded requests
  • config mock rules for different requests

Not support:

  • cookie sensitive requests, because the plugin forwards requests with cookies of the page, instead of cookies of the request domain
  • relative or local DNS parsed requests, because the mock server can not resolve them
  • HTTPS pages, unless the mock server is deployed with HTTPS (Solved by leancloud and now.sh)

How to use

1.Prepare

Install Chrome plugin, parrot-mocker, so that your pages have the ablity to intercept requests and forward to this mock server. Other usages without the plugin can refer to parrot-mocker project.

2.Visit

For example, if deployed in leancloud, please open your Chrome browser and visit index page first. Other instances like now.sh are similar.

Then visit your test page, i.e. my demo, which will send 3 different requests(xhr/jsonp/fetch) after loaded.

In the plugin, input the mock server address and click the green button. The test page will reload automatically.

Now you will find that requests are forwarded to the mock server, which are also visiable at index page. If visiting other pages in the same domain, their requests will also be forwarded to this mock server.

3.Mock

Click any request in the list, and click 'Add'. Then this request is added to mock.

Open config page, now you can edit the mock data. Remember to click 'Apply' to really use the mock data.

Refresh your test page to check whether the mock is working correctly.

Launch locally

By default, the server is launched on main port 8080, and sub-ports 8442/8443. Sub-ports can be visited by http/https correspondingly. Because my https is self-certified, if your browser gives a warning, please continue to visit.

node ./server/index.js

Or you can specify the port by an environment variable.

PORT=8888 HTTP_PORT=9442 HTTPS_PORT=9443 node ./server/index.js

To use local server, you should visit and set local address as mock server in step 2, i.e. https://127.0.0.1:8080, and other steps are similar with above.

Tips

  • In order to handles redirections well, please make sure the server can also visit itself by the host address that you input in the Chrome plugin.

License

MIT

Acknowledgement




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap