有问题的地方,我似乎连接到Server,但找不到服务器/db。

我一直试图按照本指南中的步骤为柏树9,但没有任何效果。
https://www.npmjs.com/package/cypress-sql-server
有一个答案,所以我一直在尝试使用,但我不能回复评论和添加评论,但它被删除的mods出于某种原因。这是我一直试图遵循但无法连接的答案的URL。
如何配置没有cypress.json的cypress-sql-server?(更新)
有人能给我举个例子吗?
cypress.config.ts
const { defineConfig } = require("cypress");
const sqlServer = require("cypress-sql-server");
module.exports = defineConfig({
e2e: {
setupNodeEvents(on, config) {
// allows db data to be accessed in tests
config.db = {
"userName": "x",
"password": "x",
"server": "xxx\\SQLEXPRESS",
"options": {
"database": "xxxxxx",
"encrypt": true,
"rowCollectionOnRequestCompletion": true,
"trusted_connection": true
}
}
// code from /plugins/index.js
const tasks = sqlServer.loadDBPlugin(config.db);
on('task', tasks);
return config
// implement node event listeners here
},
},
});
export default defineConfig({
chromeWebSecurity: false,
videosFolder: 'cypress/videos',
screenshotsFolder: 'cypress/screenshots',
fixturesFolder: 'cypress/fixtures',
video: false,
reporter: 'cypress-mochawesome-reporter',
reporterOptions: {
reportDir: 'cypress/reports',
charts: true,
reportPageTitle: 'xxxxxxxx',
embeddedScreenshots: true,
inlineAssets: true,
},
e2e: {
// We've imported your old cypress plugins here.
// You may want to clean this up later by importing these.
setupNodeEvents(on, config) {
return require('./cypress/plugins/index.ts')(on, config)
},
experimentalSessionAndOrigin: true,
specPattern: 'cypress/e2e/tests/orders/*',
baseUrl: 'http://localhost:4200',
},
})index.ts
const { defineConfig } = require('cypress')
module.exports = (on, config) => {
require('@cypress/code-coverage/task')(on, config);
require('cypress-mochawesome-reporter/plugin')(on);
return config;
}e2e.ts
import '@cypress/code-coverage/support';
import './commands';
import 'cypress-mochawesome-reporter/register';
import sqlServer from 'cypress-sql-server';
sqlServer.loadDBCommands();
}尝试在Server上创建一个新的sysadmin,以防出现访问问题
发布于 2022-10-25 20:10:00
您的实例的TCP/IP属性应该如下所示,以使它侦听端口1433:在IPALL上,清除TCP动态端口并将TCP端口设置为1433。

发布于 2022-10-25 20:33:00
您的配置文件中有cypress.config.js的模式和cypress.config.ts的模式,但是它不是同时存在/还是两者兼而有之。
参见示例配置。
既然您使用类型记录,请尝试
import { defineConfig } from 'cypress'
import sqlServer from 'cypress-sql-server'
const dbSettings = {
"userName": "x",
"password": "x",
"server": "xxx\\SQLEXPRESS",
"options": {
"database": "xxxxxx",
"encrypt": true,
"rowCollectionOnRequestCompletion": true,
"trusted_connection": true
}
}
export default defineConfig({
chromeWebSecurity: false,
... // other cofinfig settings
e2e: {
setupNodeEvents(on, config) {
config.db = dbSettings;
const tasks = sqlServer.loadDBPlugin(dbSettings);
on('task', tasks);
return require('./cypress/plugins/index.ts')(on, config)
},
experimentalSessionAndOrigin: true,
specPattern: 'cypress/e2e/tests/orders/*',
baseUrl: 'http://localhost:4200',
},
})https://stackoverflow.com/questions/74197951
复制相似问题