为什么在使用模拟时不引发随机错误
你可能会发现,尝试使用随机错误和模拟时,代理不会返回随机错误。 其中一个原因可能是 devproxyrc 配置中插件的顺序不正确。
代理按照在配置中定义的顺序执行插件。 在这种情况下,模拟是在随机错误之前执行的,因此,如果为 URL 定义了模拟,则请求永远不会到达随机错误插件。
如果需要随机错误和模拟,请将插件的顺序更改为:
{
"plugins": [
// [...] trimmed for brevity
{
"name": "GenericRandomErrorPlugin",
"enabled": true,
"pluginPath": "~appFolder/plugins/dev-proxy-plugins.dll",
"configSection": "genericRandomErrorPlugin"
},
{
"name": "MockResponsePlugin",
"enabled": true,
"pluginPath": "~appFolder/plugins/dev-proxy-plugins.dll",
"configSection": "mocksPlugin"
}
// [...] trimmed for brevity
],
// [...] trimmed for brevity
}
这样,将首先处理随机错误,并且代理不随机失败的任何请求都会与模拟进行比较。