Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to suppress FuncUnit unit errors in tests?

I have a FuncUnit test case wherein I open a webpage using

F.open("http://www.example.com");

There is a known issue in our page that approximately one in around 20 times the webpage would not load for whatever reason. I want to retry when it does not load. But in FuncUnit there is no way to suppress error if it fails to load the page. Is there a way to suppress error message in Funcunit?

like image 460
Sathish Avatar asked Dec 07 '16 22:12

Sathish


1 Answers

Couldn't something like this work for you?

module("test", {
  setup: function() {
    let startMeUp = () => F.open('http://www.example.com'); // unfortunately doesn't return a usable value
    let checkCondition = () => {
      // grab F(F.window), and check for a known element in the page
      return elementFound;
    };
    while(!checkCondition()) {
      // element wasn't found, so let's try it again
      startMeUp();
      // maybe set a wait here
    }
  }
});
like image 175
manonthemat Avatar answered Nov 19 '22 15:11

manonthemat