LambdaTest / testcafe-browser-provider-lambdatest

npm Plugin For TestCafe Integration With LambdaTest
https://www.lambdatest.com/
Other
16 stars 22 forks source link

Fails with "Unable to establish one or more of the specified browser connections." when the tests being ran are added to queue #10

Closed sduduzog closed 2 years ago

sduduzog commented 3 years ago
  1. When my plan is limited to 2 parallel sessions, and one is in use, running automated tests with concurency set to 2 will cause the tests to hang and eventually fail.
  2. When automated tests are already running, and another instance is started. the last instance is added to queue, this is not an issue, but the fact that this library cannot handle queuing is an issue on its own.
  3. There is no way to fail gracefully if there are connection issues to which some may be caused by the above items.

This is the error I get when I run tests and are added to the queue

Starting tunnel
{"status":"SUCCESS","message":"OK"}{"status":"SUCCESS","message":"OK"}Tunnel successfully initiated. You can start testing now
GeneralError: Unable to establish one or more of the specified browser connections. This can be caused by network issues or remote device failure.
    at BrowserSet._waitConnectionsOpened (C:\dev\yumbi-e2e-tests\node_modules\testcafe\src\runner\browser-set.js:83:30)
    at C:\dev\yumbi-e2e-tests\node_modules\testcafe\src\runner\browser-set.js:106:35
    at Bootstrapper._getBrowserConnections (C:\dev\yumbi-e2e-tests\node_modules\testcafe\src\runner\bootstrapper.js:71:16)
    at Bootstrapper._bootstrapSequence (C:\dev\yumbi-e2e-tests\node_modules\testcafe\src\runner\bootstrapper.js:179:29)
    at Bootstrapper.createRunnableConfiguration (C:\dev\yumbi-e2e-tests\node_modules\testcafe\src\runner\bootstrapper.js:238:38) {
  code: 'E1004',
  data: []
}
prateekLambda commented 3 years ago

Hi @sduduzog Thanks for sharing the Error Message. Looks like your test session went into the queue, and which is a known limitation with TestCafe. Testcafe only works over the live connection with the browser. And when the test session of Testcafe with the remote grid browser opens the instance more than the available concurrency, the test session goes into the queue. However, Testcafe does not support the queuing mechanism. As you mentioned in point number 1 and 2, this is the expected behavior of Testcafe for the queue. Although, you can create several runners for each browser and run them in series. Here is an example code to run parallel testing over LambdaTest Selenium Grid through a custom Testcafe runner.

const browsers = [ ['lambdatest:Chrome@74.0:Windows 10"', 'lambdatest:Chrome@75.0:Windows 10'], ['lambdatest:Chrome@76.0:Windows 8', 'lambdatest:Chrome@77.0:Windows 8'], ]; const runTest = async browser => { console.log('starting tests'); await createTestCafe('localhost', 1337, 1338) .then(tc => { testcafe = tc; const runner = testcafe.createRunner(); return runner .src(['web-tests/*.ts']) .browsers(browser) .run(); }) .then(async failedCount => { console.log('Tests failed: ' + failedCount); await testcafe.close(); return; }); } const runAllBrowsers = async () => { for (const browser of browsers) { await runTest(browser); } }

Thanks

dubesar commented 2 years ago

@sduduzog You can try out the new version of 2.0.10, with a new flag LT_TUNNEL_NUMBER Docs - https://www.lambdatest.com/support/docs/npm-plugin-for-testcafe-integration-with-lambdatest/