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)

2 Answers 2

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.

Sign up to request clarification or add additional context in comments.

Comments

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.