-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: allow to call mockHttpclient multi times #165
Conversation
lib/mock_httpclient.js
Outdated
return mockUrl.test(`${requestOrigin}${path}`); | ||
for (const config of mockConfigs) { | ||
if (config.mockUrl.test(`${requestOrigin}${path}`)) { | ||
mm(app, '__httpclientNextMockConfigIndex', config.mockConfigIndex); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
有并发请求的时候会不会有问题?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
两次 mock,Promose.all 中的请求都匹配了。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
只会命中第一个 mockUrl
app.mockHttpclient(/\/mock_url/, { | ||
data: Buffer.from('mock 1 match response'), | ||
}); | ||
app.mockHttpclient(/\/mock_url/, { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
加了相同 mock 校验,只会返回第一个 mock 结果
@@ -63,6 +63,9 @@ module.exports = app => { | |||
* @return {Context} this | |||
*/ | |||
|
|||
const MOCK_CONFIGS = Symbol('MOCK_CONFIGS'); | |||
const MOCK_CONFIG_INDEX = Symbol('MOCK_CONFIG_INDEX'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
换成 Symbol 不被外部获取到
[skip ci] ## [5.10.9](v5.10.8...v5.10.9) (2023-11-08) ### Bug Fixes * allow to call mockHttpclient multi times ([#165](#165)) ([370e42d](370e42d))
closes #164
Checklist
npm test
passesAffected core subsystem(s)
Description of change