I tried to use index the newly created contents to be able to test a page, but the problem is most of the times the tests fails, because the indexing process not finished yet until the contents starts checking. (i.e. if I stop before pageload with a breakpoint the testing, then the next steps always pass)
Method 1:
$search_api_index = search_api_index_load('SEARCH_API_INDEX_ID');
search_api_index_items($search_api_index);
Method 2:
search_api_cron();
The question, how can I call the indexing to wait until it's fully indexed before it goes forward?