testcafe icon indicating copy to clipboard operation
testcafe copied to clipboard

Allow to setup 'skip-js-error' option only for specified pages.

Open miherlosev opened this issue 7 years ago • 19 comments

Use case: The tested site contains parts (ad blocks, external service pages and etc.) that have js errors and cannot be controlled by test writer.

We need a conditional behavior for this case:

  • for uncontrolled pages need to skip js errors.
  • for other pages need to handle js errors.

So, we need a way to setup 'skip-js-error' option only for specified pages.

Based on https://stackoverflow.com/questions/52031129/skip-js-errors-on-specific-test-cases

miherlosev avatar Aug 27 '18 11:08 miherlosev

Perhaps instead of at the page level it could be done using the test controller: t.ignoreJSErrors(true / false)

ljowen avatar Aug 28 '18 01:08 ljowen

Yes it seems to me this comes up somewhat regularly (#2033, #3747). In our case there is some ad-script on a 3rd party page that throws an error. And this means we have to set --skip-js-error for all tests. This is really sad, since:

  • we have to hope that errors get caught still by also breaking functionality
  • we have one less incentive for developers to handle errors properly

bxt avatar Jul 24 '19 13:07 bxt

Hello @bxt,

Thank you for sharing your scenario with us. We will take it into account when we are ready to implement this feature.

aleks-pro avatar Jul 25 '19 11:07 aleks-pro

Exactly the same problem as @bxt

Other than that having many small wholes in TC (new tab opening, visibility checking...) because of that not able to write stable and efficient tests.

bartzielonka avatar Aug 22 '19 13:08 bartzielonka

We would also appreciate to get this new feature.

GrafDa avatar Sep 02 '19 11:09 GrafDa

Need this too. Hammerhead is super flakey already with our application's ajax calls. Now we have a thirdparty JS window that does a window.setTimeout which causes to hammerhead to blow up. We have no way to trap the error without disabling it for all of our tests.

alienintheheights avatar Mar 09 '20 20:03 alienintheheights

@alienintheheights Could you describe your case in greater detail? Does your test lead to any exceptions in Hammerhead scripts?

Dmitry-Ostashev avatar Mar 10 '20 15:03 Dmitry-Ostashev

This would also help us. A few of my test cases involve validating I can visit another site which often has a ton of JS errors. Being able to skip JS errors for a single test would be convenient.

pterofractal avatar Apr 10 '20 15:04 pterofractal

Took like two years to decide that this is a very interesting feature ? we can tell from @bxt that much people would need it.

gothraven avatar Apr 30 '20 10:04 gothraven

Hi @gothraven

We confirm that this a good extension of the skip-j-error feature. But it's not what we plan to implement in the near future. At present, we are working on two large features: Capability to perform testing in multiple browser windows and Selector Debug Panel. After these features are implemented, we will concentrate our resources on other features.

miherlosev avatar Apr 30 '20 15:04 miherlosev

@miherlosev is there any way I can help with this small feature ?

gothraven avatar Apr 30 '20 15:04 gothraven

@gothraven, You can submit your PR with this feature implementation.

AlexSkorkin avatar May 01 '20 07:05 AlexSkorkin

Guys,

There is an example that demonstrates how to extend the built-in error tracking functionality and skip JavaScript errors by a predicate function.

miherlosev avatar Oct 09 '20 08:10 miherlosev

This would be great to be able to overwrite the default config value within a particular test - we have issues loading certain external js files related to analytics within some pages owned by other teams which causes problems when doing a smoke test of our micro frontend.

rushby avatar May 04 '21 15:05 rushby

Hi @rushby

Thank you for sharing this use case. You can use a workaround until this feature is implemented.

miherlosev avatar May 05 '21 08:05 miherlosev

Hello,

We are also running into this with third party sites. It would be nice to set skipjserrors = true via the controller in a step in a test. Right now, it's just a global setting.

jbradenclickfunnels avatar Jan 17 '22 19:01 jbradenclickfunnels

Same here, we have a specific test that throws an error which we have no control to (external script), now we need skip all js errors for all our tests. Would be really great if we could enable this option only on one test!

knodschi avatar Feb 10 '22 16:02 knodschi

Would really appreciate this as well. My hesitancy in skipping javascript errors globally is that my tests would miss something I need to see. Being able to set this by page or even by individual test would be incredibly helpful. Thank you!!

jmosley5 avatar Feb 11 '22 20:02 jmosley5

Hi @jmosley5,

Thank you for your opinion. This feature has a high priority for us, and it is in our roadmap. You can use a workaround until this feature is implemented.

miherlosev avatar Feb 28 '22 08:02 miherlosev

Release v2.0.0-rc.1 addresses this.

github-actions[bot] avatar Aug 25 '22 10:08 github-actions[bot]

Release v2.0.0-rc.1 addresses this.

github-actions[bot] avatar Aug 25 '22 10:08 github-actions[bot]