6

I'm testing functionality that includes redirecting to an external page which I do not control. This page is throwing errors causing the test to fail.

Is there a way to ignore js errors for one specific test only? (I want errors on my site to cause a test fail)

Alex Skorkin
  • 4,264
  • 3
  • 25
  • 47
ioseph
  • 1,887
  • 20
  • 25

2 Answers2

7

At present, TestCafe does not allow to do this. I've created a proposal in TestCafe repository for your use case. Track it to be aware about progress.

UPDATE:

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

Alex Skorkin
  • 4,264
  • 3
  • 25
  • 47
mlosev
  • 5,130
  • 1
  • 19
  • 31
1

I'm happy to announce that TestCafe of version 2.0 and above provides a variety of options to skip JS errors on the testing pages conditionally at different levels (a whole test run, fixture, a whole test, etc.). To achieve this, you can use all TestCafe's interfaces CLI, a program API, and the config file. Here is a small feature example for skipping errors with a specified message and page URL:

fixture(**"My tests"**)
    .skipJsErrors({
        **message**: /Some expected message/ig
        **pageUrl**: /some-ads-site/
    });

Read more about this functionality in the Docs.

Helen Dikareva
  • 1,026
  • 6
  • 7