Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bugszhou/mini-program-request-mock
小程序request接口mock
https://github.com/bugszhou/mini-program-request-mock
Last synced: 1 day ago
JSON representation
小程序request接口mock
- Host: GitHub
- URL: https://github.com/bugszhou/mini-program-request-mock
- Owner: bugszhou
- Created: 2021-06-11T14:59:12.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2021-06-14T15:41:31.000Z (over 3 years ago)
- Last Synced: 2025-01-04T03:14:29.018Z (22 days ago)
- Language: TypeScript
- Size: 103 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# mini-program-request-mock
小程序 request 接口 mock,在 jest 中是`mini-program-request-mock`模拟`request`。
- 依赖于 jest
## Usage
```javascript
import RequestMock from "mini-program-request-mock";describe("request", () => {
it("success", () => {
new RequestMock({
url: "http://baidu.com",
}).success({
statusCode: 200,
data: { data: 123, msg: "success" },
headers: "",
});wx.request({
url: "http://baidu.com",
success(res) {
console.log("success: ", res);
},
});
});it("fail", () => {
new RequestMock()
.get({
url: "http://baidu.com",
})
.success({
statusCode: 200,
data: { data: 555, msg: "success" },
headers: "",
});wx.request({
url: "http://baidu.com",
success(res) {
console.log("success1: ", res);
},
});
});
});
```