sql-servercypressbrowserstack

Calling cy.sqlServer() Cypress Commands from BrowserStack to an Internal Database


I am attempting to run Cypress for a web app in BrowserStack. I can run the tests locally successfully. When I try to upload them to BrowserStack with browserstack-cypress run the tests fail due to:

CypressError: `cy.task('sqlServer:execute')` failed with the following error:

> Failed to lookup instance on db.internalapps.lan - getaddrinfo ENOTFOUND db.internalapps.lan

The problem is these tests are using the cy.sqlServer() command from the cypress-sql-server npm package to do some database setup and need to call the application database. The web app is public facing so I only need these SQL statements to execute locally on the machine in order for them to hit that database. I already setup the local server agent and verified my uploaded package in BrowserStack says local testing is on.

BrowserStack.json:

"connection_settings": {
    "local": true,
    "local-identifier": "MyLocalConnection01"
},

Solution

  • I read your query and understand that you wish to access your database behind your network via the local connection. ā€‹ Since your database is only accessible from an internal network, the connection will not happen because with Local binary only HTTP, HTTPS, and Web Socket connections over TCP are possible as Local binary uses an HTTP proxy underneath.

    The SQL servers require a different protocol, such as sqlserver:// or postgres://, etc., which BrowserStack Local binary currently cannot communicate over. Hence, any SQL protocols will not work via the same.

    ā€‹