你可以在运行 testcafe-hammerhead 代理独立版本时放置钩子的位置在哪里?

huangapple go评论60阅读模式
英文:

Where do I place hooks when running testcafe-hammerhead Proxy standalone?

问题

我知道TestCafe支持通过TestCafe-Hammerhead Web代理传递的请求的各种钩子。在我的项目中,我独立运行代理,而不使用TestCafe框架本身,我想知道在这种情况下是否仍然支持钩子,如果支持的话,添加它们的正确方法是什么。

目前,我通过修改请求流水线代码来添加一些逻辑,但我更希望以不那么侵入性的方式修改请求/响应,最好通过像主框架暴露的钩子系统来实现。

英文:

I know testcafe supports various hooks for requests that are going through the testcafe-hammerhead web proxy. In my project I'm running the proxy standalone without the testcafe framework itself and I am wondering if hooks are still supported here, and if so, what the correct way of adding them would be.

Currently I'm adding some logic by modifying the request-pipeline code, however I would prefer a less intrusive way of modifying requests / responses, ideally via a hook system like the main framework exposes.

答案1

得分: 0

无法明确地向testcafe-hammerhead添加RequestHook的方法,因为testcafe-hammerhead的这个特性并不打算单独使用。如果您仍然需要添加Request Hook,请参考TestCafe中的实现方式:
https://github.com/DevExpress/testcafe/blob/5e72bea662a89c8bbe8573a3d8a8609c3b03524a/src/test-run/index.ts#L502

或者,在testcafe-hammerhead的测试中查看:
https://github.com/DevExpress/testcafe-hammerhead/blob/3384acaf7256ce2a7427053562e1149381887f73/test/server/proxy/request-hooks-test.js
https://github.com/DevExpress/testcafe-hammerhead/blob/148e9941feb64f4f555c337c1c1fc01074bee822/test/server/request-hook-test.js

英文:

There is no explicit way to add RequestHook to testcafe-hammerhead, since this testcafe-hammerhead feature is not intended to be used separately. If you still need to add Request Hook, you can see how it is implemented in TestCafe:
https://github.com/DevExpress/testcafe/blob/5e72bea662a89c8bbe8573a3d8a8609c3b03524a/src/test-run/index.ts#L502

Or, in testcafe-hammerhead tests:

https://github.com/DevExpress/testcafe-hammerhead/blob/3384acaf7256ce2a7427053562e1149381887f73/test/server/proxy/request-hooks-test.js
https://github.com/DevExpress/testcafe-hammerhead/blob/148e9941feb64f4f555c337c1c1fc01074bee822/test/server/request-hook-test.js

huangapple
  • 本文由 发表于 2023年6月22日 03:59:29
  • 转载请务必保留本文链接:https://go.coder-hub.com/76526739.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定