英文:
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
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论