Giter VIP home page Giter VIP logo

mocker's Introduction

Mocker

HTTP/HTTPS 模拟响应工具,支持浏览器和本地服务器请求,可用来模拟接口返回,便于开发及测试。
基于 Node.jsElectron 构建。

界面预览

image

功能特色

  • 基于代理服务器机制并自动设置
  • 无需修改现有代码中的请求链接,不污染源码
  • 支持浏览器和本地服务器的请求
  • 支持 HTTP 和 HTTPS 请求
  • 可以完全自定义响应的内容

🎁 应用下载

https://github.com/eshengsky/Mocker/releases

注意

  • 目前仅支持 Windows 平台
  • 请确保你的 Windows 已安装 PowerShell(Win7 及以上版本系统通常已默认安装)
  • 尽可能以管理员身份运行应用

本地调试

首先安装 Node.jsNPM

安装依赖包

$ npm install

启动应用

$ npm start

如果想以 debug 模式启动应用,请使用

$ npm run dev

Enjoy it! 😄

如何打包

可以使用 electron-packager 对程序进行打包以方便分发应用。

全局安装electron-packager

$ npm install -g electron-packager

打包应用

在完成了 本地调试 全部操作的前提下,进入需要打包的应用的目录,执行:

$ npm run package

注意事项

打包过程中 electron-packager 会自动下载所需的文件并存放到 user/你的用户名/.electron 中,自动下载可能会很慢,建议直接在 Electron Release 使用下载工具进行下载并放到上述目录中。

常见问题

  • 如何模拟 https 请求?
    首先点击 Mocker 菜单栏 SSL - 下载证书,将安全证书下载保存到任意位置,再点击菜单栏 SSL - 打开证书管理器,在弹出的界面中选择 受信任的根证书颁发机构 - 证书,右击选择 所有任务 - 导入,要导入的文件请选择你刚刚下载的 ca.pem 文件,其他选项默认,完成导入。

  • 如何模拟本地服务器(如 Node.js 服务器)发送的请求?
    Mocker 工具是基于代理服务器的,所以你只需要将对应的代理配置成 http://127.0.0.1:2018https://127.0.0.1:2018 即可。以 Node.js 服务器为例,将启动脚本设置为 set HTTP_PROXY=http://127.0.0.1:2018&&node ./bin/www

  • 为什么关闭 Mocker 后,无法正常上网了?
    在正常情况下,Mocker 会在退出程序前自动将系统代理重置为空,但遇到一些特殊情况(如手动杀死进程、直接关机、程序异常等),系统代理可能不会自动重置,此时你需要手动进行设置,方式:打开 IE - Internet 选项 - 连接 - 局域网设置,取消勾选代理服务器。

  • 我发现无法正常使用,或者有异常错误提示?
    尝试使用管理员身份运行软件(链接),如果问题依旧,请提Issue。

许可协议

The MIT License (MIT)

Copyright (c) 2018 孙正华

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

mocker's People

Contributors

eshengsky avatar

Watchers

James Cloos avatar DrSolbridgeLuke avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.