testcafe

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


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.


Solution

  • 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