ioseph
ioseph

Reputation: 1917

--skip-js-errors on specific test cases

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)

Upvotes: 6

Views: 1258

Answers (2)

Helen Dikareva
Helen Dikareva

Reputation: 1036

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.

Upvotes: 1

mlosev
mlosev

Reputation: 5227

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.

Upvotes: 7

Related Questions