Search code examples
javascriptunit-testingphantomjsyuigrover

YUI test error: window.getYUITestResults()


I have error when I run the YUI tests via PhantomJS using grover:

TypeError: 'undefined' is not a function (evaluating 'window.getYUITestResults()')

I found that this error occurs because I use location.reload() and PhantomJS have problem with this.


Solution

  • So here is the solution:

    if (window['phantom'] || window['_phantom']) return;
    location.reload();
    
    • window['phantom'] - indicates presence PhantomJS, but when you use grover this property is absent :(
    • window['_phantom'] - indicates presence PhantomJS using grover

    Using this simple solution you can skip as may code as you want, good luck!