Search code examples
testingautomated-testse2e-testingtestcafebrowserstack

TestCafe-BrowserStack Script hangs and won't terminate when the tested page throws 500, or general error like "not enough memory"


Sometime when the tested page throws unexpected error "not a code or javascript error", such as 500 or not enough memory, the script won't terminate and waits for up to 7200 seconds, which is the allowed session time giving by browserStack, then it times out.

I would like to know if I can force my scripts to terminate (or consider it as a failure) whenever it encounters such a behavior instead of waiting that long.


Solution

  • You can reduce the value of IDLE TIMEOUT in the TestCafe code: https://github.com/DevExpress/testcafe-browser-provider-browserstack/blob/1100c372b52a1043c90d621f461f4bd0f7bd0ddf/src/backends/js-testing.js#L9

    Instead of 1800 can you reduce it to 300 seconds assuming your test locally completes in 2 mins. Please note that the minimum value is 60 seconds.

    You could also run the following command to delete the existing created and queued worker: a. Command to find existing worker id using terminal prompt

    curl -u "your_username:your_access_key" https://api.browserstack.com/5/workers | python -m json.tool | grep id | awk {'print $2'} | sed 's/.$//'
    

    b. Command to delete workers using terminal prompt

    curl -u "your_username:your_access_key" -X DELETE "https://api.browserstack.com/5/worker/worker_id"