cypress connect with Microsoft SQL but error occured #27350
Unanswered
Habib0
asked this question in
Questions and Help
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
cypress.json file
{
"env": {
"db": {
"user": "habib007",
"password": "123",
"server": "DESKTOP-KFJKDD2",
"database": "testdb",
"options": {
"trustedConnection": false
}
}
}
}
index.js plugin file
const sql = require("mssql");
async function queryTestDb(query, config) {
try {
await sql.connect(config.env.db);
const result = await sql.query(query);
return result.recordset;
} catch (error) {
throw error;
} finally {
sql.close();
}
}
module.exports = (on, config) => {
on('task', {
queryDb: (query) => {
return queryTestDb(query, config);
},
});
};
intergration file
describe('Database Testing', () => {
it('should retrieve data from the database', () => {
});
package.json file:
"devDependencies": {
"@babel/core": "^7.22.9",
"@babel/preset-env": "^7.22.9",
"babel-loader": "^9.1.3",
"cypress-sql-server": "^1.0.0",
"mssql": "^9.1.1",
"mysql": "^2.18.1",
"tedious": "^16.2.0"
}
}
but error occured:
task
queryDb, SELECT * FROM users
CypressError
cy.task('queryDb') failed with the following error:
Failed to connect to DESKTOP-KFJKDD2:1433 - Could not connect (sequence).
Beta Was this translation helpful? Give feedback.
All reactions