code: async function(testFx, onReady, timeOutMillis) {
  		return new Promise((resolve, reject) => {
  			var maxtimeOutMillis = timeOutMillis ? timeOutMillis : 3000, //< Default Max Timout is 3s
  					start = new Date().getTime(),
  					condition = false, interval;
  
  			interval = setInterval(async function() {
  				clearInterval(interval);
  				condition = await testFx();
  				if ((new Date().getTime() - start >= maxtimeOutMillis) || condition ) {
  					if(!condition) {
  						// If condition still not fulfilled (timeout but condition is 'false')
  						reject(new Error( "Timeout waiting for CSS rules" ));
  						return;
  					}
  
  					resolve(await onReady());
  				}
  			}, 250); //< repeat check every 250ms
  		});
  	}
docs: Wait until the test condition is true or a timeout occurs. Useful for waiting
  on a server response or for a ui change (fadeIn, etc.) to occur.
  
  @param testFx javascript condition that evaluates to a boolean,
  it can be passed in as a string (e.g.: "1 == 1" or "$('#bar').is(':visible')" or
  as a callback function.
  @param onReady what to do when testFx condition is fulfilled,
  it can be passed in as a string (e.g.: "1 == 1" or "$('#bar').is(':visible')" or
  as a callback function.
  @param timeOutMillis the max amount of time to wait. If not specified, 3 sec is used.