1 year ago
#77596
shaveax
How to connect to a redshift database with Cypress?
I am having issues trying to connect to a redshift database on Cypress, I've followed the instructions from the official cypress-sql-server webpage, please see my configurations files below
--> cypress.json
"db": {
"userName": "MY_USERNAME",
"password": "MY_PASSWORD",
"server": "MY_SERVER",
"options": {
"database": "MY_DATABASE",
"encrypt": true,
"rowCollectionOnRequestCompletion" : true,
}
}
--> package.json
"devDependencies": {
"@shelex/cypress-allure-plugin": "^2.23.0",
"cypress": "^9.2.1",
"cypress-cucumber-preprocessor": "^4.3.1",
"cypress-mochawesome-reporter": "^2.3.0",
"cypress-sql-server": "^1.0.0"
}
--> cypress/plugins/index.js
const sqlServer = require('cypress-sql-server');
const dbConfig = require('../../cypress.json');
module.exports = (on, config) => {
// `on` is used to hook into various events Cypress emits
// `config` is the resolved Cypress config
/** SQL Server configuration */
tasks = sqlServer.loadDBPlugin(dbConfig.db);
on('task', tasks);
return config;
}
--> cypress/integration/test_spec.js
describe("My First Test", () => {
it("Does not do much!", () => {
cy.sqlServer('SELECT *');
});
});
I have two behaviors
The first one is when I specify the database port on the cypress.json like this:
"db": {
"userName": "MY_USERNAME",
"password": "MY_PASSWORD",
"server": "MY_SERVER",
"options": {
"database": "MY_DATABASE",
"encrypt": true,
"rowCollectionOnRequestCompletion" : true,
"port": 5439
}
}
I got a socket hang up error, which is the following
My First Test
The following error was thrown by a plugin. We stopped running your tests because a plugin crashed. Please check your plugins file (
../cypress/plugins/index.js
)ConnectionError: Connection lost - socket hang up at ConnectionError (../node_modules/tedious/lib/errors.js:13:12) at Connection.socketError (../node_modules/tedious/lib/connection.js:1012:26) at Connection.socketEnd (../node_modules/tedious/lib/connection.js:1031:12) at Socket. (../node_modules/tedious/lib/connection.js:890:14) at Socket.emit (events.js:387:35) at endReadableNT (internal/streams/readable.js:1317:12) at processTicksAndRejections (internal/process/task_queues.js:82:21)
The second behavior is when I no specify the port on the cypress.json file, Cypress is taking the port "1433" (which is not the desired) it fail to connect:
- My First Test Does not do much!: CypressError:
cy.task('sqlServer:execute')
failed with the following error:Failed to connect to MY_SERVER:1433 in 15000ms
javascript
sql
node.js
amazon-redshift
cypress
0 Answers
Your Answer