-
Notifications
You must be signed in to change notification settings - Fork 0
/
cypress.config.js
64 lines (61 loc) · 1.9 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
53
54
55
56
57
58
59
60
61
62
63
64
const { defineConfig } = require("cypress");
const { resetTestDatabase, executeSqlFile } = require('./cypress/__utils__/db-setup.js')
const fs = require('fs')
module.exports = defineConfig({
e2e: {
setupNodeEvents(on, config) {
on('task', {
log(message) {
// Makes it so we can use this within tests to get visibility:
// cy.task("log", "some thing to log...");
console.log(message +'\n\n');
return null;
},
})
on('before:run', async (details) => {
await resetTestDatabase()
await executeSqlFile('./tests.sql')
})
on('after:run', async (results) => {
// results will look something like this when run via `cypress run`:
// {
// totalDuration: 81,
// totalSuites: 0,
// totalTests: 1,
// totalFailed: 0,
// totalPassed: 1,
// totalPending: 0,
// totalSkipped: 0,
// browserName: 'electron',
// browserVersion: '59.0.3071.115',
// osName: 'darwin',
// osVersion: '16.7.0',
// cypressVersion: '3.1.0',
// config: {
// projectId: '1qv3w7',
// baseUrl: 'http://example.com',
// viewportWidth: 1000,
// viewportHeight: 660,
// // ... more properties...
// }
// // ... more properties...
// }
// }
// results will be undefined in interactive mode
if (results) {
// Deletes the build folder that the test run
// generates. Only works if we supply a callback
// function:
fs.rmdir('build', {recursive: true}, () => {})
console.log(
results.totalPassed,
'out of',
results.totalTests,
'passed'
)
}
})
},
baseUrl: 'http://localhost:5002',
}
});