Establishing mySql connection over SSH tunnel in Cypress #19419
-
Hi there,
I have successfully connected to the DB using same library in webdriver i/o in the past and had no issues. This also perfectly works in plane node.js if I clean out Cypress.env and cy.readFile obviously. However, in Cypress, I get error: I have also tried establishing this connection in plugins/index.js file and called it in my test via From what I understand I am having this issue due to 'Cypress' running in the browser and in case on plugins/index.js - it communicates with Cypress' own background node.js process (from Electron), not one that would be supplied by host (my) environment. Is there a workaround for this ? From cypress DEBUG logs it seems like my error is thrown by "ssh2-streams" package. Any help would be appreciated. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
Cypress spec file runs in the browser, thus it cannot directly execute (in most cases) code that is meant to run in Node. To run in Node you should use the plugin file that runs in a separate process which can communicate with the spec via |
Beta Was this translation helpful? Give feedback.
-
If anyone comes across this and needs a code for this specific library, here is my code:
and here is how I used it in a test example:
|
Beta Was this translation helpful? Give feedback.
Cypress spec file runs in the browser, thus it cannot directly execute (in most cases) code that is meant to run in Node. To run in Node you should use the plugin file that runs in a separate process which can communicate with the spec via
cy.task
command. See a typical example in the blog post https://glebbahmutov.com/blog/verify-phone-part-two/