-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathcypress.config.js
105 lines (98 loc) · 2.96 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/* eslint-disable @typescript-eslint/no-require-imports */
import * as fs from 'fs';
const {
injectQuasarDevServerConfig,
} = require('@quasar/quasar-app-extension-testing-e2e-cypress/cct-dev-server');
const { defineConfig } = require('cypress');
const {
addMatchImageSnapshotPlugin,
} = require('cypress-image-snapshot/plugin');
const { getAppConfig } = require('src/utils/get_app_conf');
module.exports = defineConfig({
fixturesFolder: 'test/cypress/fixtures',
screenshotsFolder: 'test/cypress/screenshots',
videosFolder: 'test/cypress/videos',
video: true,
requestTimeout: 12000,
e2e: {
setupNodeEvents(on, config) {
addMatchImageSnapshotPlugin(on, config);
require('cypress-terminal-report/src/installLogsPrinter')(on, {
printLogsToConsole: 'onFail',
includeSuccessfulHookLogs: false,
printLogsToFile: 'onFail',
outputRoot: config.projectRoot + '/test/cypress/logs/',
specRoot: 'e2e/',
outputTarget: {
'cypress-logs|txt': 'txt',
},
});
on('task', {
getAppConfig,
fileExists,
deleteFile,
readFile,
});
return config;
},
baseUrl: 'http://localhost:9000/',
supportFile: 'test/cypress/support/e2e.js',
specPattern: 'test/cypress/e2e/**/*.cy.{js,jsx,ts,tsx}',
defaultCommandTimeout: 60000,
},
component: {
setupNodeEvents(on, config) {
addMatchImageSnapshotPlugin(on, config);
require('cypress-terminal-report/src/installLogsPrinter')(on, {
printLogsToConsole: 'onFail',
includeSuccessfulHookLogs: false,
printLogsToFile: 'onFail',
outputRoot: config.projectRoot + '/test/cypress/logs/',
specRoot: 'component/',
outputTarget: {
'cypress-logs|txt': 'txt',
},
});
on('task', {
getAppConfig,
});
return config;
},
supportFile: 'test/cypress/support/component.js',
specPattern: 'src/**/*.cy.{js,jsx,ts,tsx}',
indexHtmlFile: 'test/cypress/support/component-index.html',
devServer: injectQuasarDevServerConfig(),
defaultCommandTimeout: 60000,
excludeSpecPattern: ['*/*/**/RoutesMap.cy.js'], // RoutesMap.cy.js file tests REQUIRE REVIEW/REFACTOR/EXTENDS tests
},
});
// Task to clean up created files after testing boilerplate script
function deleteFile(path) {
return new Promise((resolve, reject) => {
fs.unlink(path, (err) => {
if (err) reject(err);
// return null to indicate Cypress task success
else resolve(null);
});
});
}
// Task to check the existence of a script-generated file
function fileExists(path) {
return new Promise((resolve) => {
fs.access(path, fs.constants.F_OK, (err) => {
if (err) {
resolve(false);
} else {
resolve(true);
}
});
});
}
function readFile(path) {
return new Promise((resolve) => {
if (fs.existsSync(path)) {
resolve(fs.readFileSync(path, 'utf8'));
}
resolve(null);
});
}