-
Notifications
You must be signed in to change notification settings - Fork 2
/
cypress.config.js
52 lines (48 loc) · 1.34 KB
/
cypress.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
const { defineConfig } = require("cypress");
// This is for db data testing/checking (CANNOT GET DATA AND CHECK VIA CYPRESS)
//For connecting to SQL Server
const mysql = require("mysql2");
function queryTestDb(query, config) {
// creates a new mysql connection using credentials from cypress.json env's
const connection = mysql.createConnection(config.env.db);
// start connection to db
connection.connect();
// exec query + disconnect to db as a Promise
return new Promise((resolve, reject) => {
connection.query(query, (error, results) => {
if (error) reject(error);
else {
connection.end();
return resolve(results);
}
});
});
}
module.exports = defineConfig({
numTestsKeptInMemory: 20,
defaultCommandTimeout: 30000,
e2e: {
setupNodeEvents(on, config) {
on("before:browser:launch", (browser = {}, launchOptions) => {
if (browser.name === "chrome") {
launchOptions.args.push("--mute-audio");
}
return launchOptions;
});
on("task", {
queryDb: (query) => {
return queryTestDb(query, config);
},
}); //For running sql query
},
baseUrl: "http://localhost:8080",
},
env: {
db: {
host: "localhost",
user: "root",
password: "helloworld",
database: "doenet_local",
},
},
});