testcafe icon indicating copy to clipboard operation
testcafe copied to clipboard

Mechanism to not inject hammerhead code into JS resources at runtime

Open leojh opened this issue 3 years ago • 6 comments

What is your Scenario?

Currently, Test Cafe uses a reverse proxy which acts like a man in the middle and injects Test Cafe/Hammerhead specific code into the main HTML document and also all linked JavaScript resources. The problem with this injection is that for a lot of cases it's very intrusive and breaks all sourcemaps that are associated with the code. The specific problem it creates for me is that as the tests run, and the application throws runtime exceptions, our error reporting tool (Sentry), cannot link to the sourcemaps it has since the stack frames no longer match.

What are you suggesting?

There should be a package that we import, or a webpack loader, that basically enables the hammerhead code without having to inject it adhoc at runtime.

What alternatives have you considered?

There are none other than going with a different tool that does not do adhoc injecting at runtime.

Additional context

No response

leojh avatar Mar 03 '22 16:03 leojh

Hi @leojh

TestCafe is based on code injection into the tested page. It's necessary for the Smart assertion mechanisms and Built-in wait mechanisms. So, it's hard to work without code injection and we will not implement such capability. We will consider possible issues separately.

The case with support for sourcemaps is described.

You can prepare a simple example illustrating the issue you found and attach it here.

alexfi1in avatar Mar 07 '22 10:03 alexfi1in

This issue was automatically closed because there was no response to our request for more information from the original author. Currently, we don't have enough information to take action. Please reach out to us if you find the necessary information and are able to share it. We are also eager to know if you resolved the issue on your own and can share your findings with everyone.

no-response[bot] avatar Mar 17 '22 11:03 no-response[bot]

This is a real shame since there shouldn't be a need to inject the code. The developer should have the option to just simply include hammerhead as a dependency and have the application be under test using the exact code that is deployed without injection. Breaking the source maps is unfortunately a pretty serious side effect currently.

leojh avatar May 04 '22 23:05 leojh

I agree with you that there are several negative side effects related to using proxy. We have plans to implement the capability to run tests without using the testcafe-hammerhead proxy. We will announce it once it is implemented.

miherlosev avatar May 06 '22 07:05 miherlosev

@miherlosev any recent convos or updates on your end about this? btw we're also happy to help out on the implementation side if you need that.

leojh avatar Jul 26 '22 20:07 leojh

Hi @leojh,

Thank you for your offer to help. At present, we are working on the prototype. Later, we will create a list of tasks to make the prototype more stable and functional. If there are tasks that can be done by non-team contributors, we will notify you.

miherlosev avatar Jul 28 '22 07:07 miherlosev

Hi @leojh,

The new test run mode became the default mode in [email protected]. Please run tests with the latest TestCafe version and let us know your results.

miherlosev avatar Jun 30 '23 07:06 miherlosev

This issue was automatically closed because there was no response to our request for more information from the original author. Currently, we don't have enough information to take action. Please reach out to us if you find the necessary information and are able to share it. We are also eager to know if you resolved the issue on your own and can share your findings with everyone.

github-actions[bot] avatar Jul 10 '23 08:07 github-actions[bot]