-
Notifications
You must be signed in to change notification settings - Fork 20
/
cypress.config.js
154 lines (131 loc) · 4.6 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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
const { defineConfig } = require('cypress');
const path = require('path');
const globby = require('globby');
const converter = require('json-2-csv');
const { downloadFile } = require('cypress-downloadfile/lib/addPlugin');
const { rmdir, unlink } = require('fs');
const fs = require('fs');
const allureWriter = require('@shelex/cypress-allure-plugin/writer');
const { cloudPlugin } = require('cypress-cloud/plugin');
const registerReportPortalPlugin = require('@reportportal/agent-js-cypress/lib/plugin');
const webpackPreprocessor = require('@cypress/webpack-batteries-included-preprocessor');
const delay = async (ms) => new Promise((res) => setTimeout(res, ms));
const reportportalOptions = {
apiKey: process.env.CI_API_KEY ? process.env.CI_API_KEY : '',
restClientConfig: {
timeout: 360000,
},
};
module.exports = defineConfig({
retries: {
runMode: 0,
openMode: 0,
},
numTestsKeptInMemory: 1,
viewportWidth: 1920,
viewportHeight: 1080,
video: false,
defaultCommandTimeout: 51000,
pageLoadTimeout: 60000,
downloadsFolder: 'cypress/downloads',
env: {
OKAPI_HOST: 'https://folio-testing-cypress-okapi.ci.folio.org',
EDGE_HOST: 'https://folio-testing-cypress-edge.ci.folio.org',
EDGE_API_KEY: '',
OKAPI_TENANT: 'diku',
diku_login: 'diku_admin',
diku_password: 'admin',
z3950_login: 'z3950Admin',
z3950_password: 'password',
is_kiwi_release: false,
downloadTimeout: 2000,
allure: true,
allureReuseAfterSpec: true,
grepFilterSpecs: true,
grepOmitFiltered: true,
rtrAuth: true,
ecsEnabled: false,
},
reporterOptions: reportportalOptions,
e2e: {
async setupNodeEvents(on, config) {
on('file:preprocessor', webpackPreprocessor());
allureWriter(on, config);
on('task', {
log(message) {
// eslint-disable-next-line no-console
console.log(message);
return null;
},
async findFiles(mask) {
if (!mask) {
throw new Error('Missing a file mask to search');
}
const list = await globby(mask);
if (!list.length) {
return null;
}
return list;
},
convertCsvToJson(data) {
const options = { excelBOM: true, trimHeaderFields: true, trimFieldValues: true };
return converter.csv2json(data, options);
},
downloadFile,
deleteFolder(folderName) {
return new Promise((resolve, reject) => {
// eslint-disable-next-line consistent-return
rmdir(folderName, { maxRetries: 10, recursive: true }, (err) => {
if (err && err.code !== 'ENOENT') {
return reject(err);
}
resolve(null);
});
});
},
deleteFile(pathToFile) {
return new Promise((resolve, reject) => {
// eslint-disable-next-line consistent-return
unlink(pathToFile, (err) => {
if (err && err.code !== 'ENOENT') {
return reject(err);
}
resolve(null);
});
});
},
readFileFromDownloads(filename) {
const downloadsFolder =
config.downloadsFolder || path.join(__dirname, '..', '..', 'Downloads');
const filePath = path.join(downloadsFolder, filename);
return fs.readFileSync(filePath, 'utf-8');
},
});
// keep Cypress running until the ReportPortal reporter is finished. this is a
// very critical step, as otherwise results might not be completely pushed into
// ReportPortal, resulting in unfinished launches and failing merges
on('after:run', async (result) => {
if (result) {
if (globby.sync('rplaunchinprogress*.tmp').length > 0) {
// eslint-disable-next-line no-console
console.log('Report portal. Await for a 20s...');
await delay(20000);
}
}
});
// fix for cypress-testrail-simple plugin
if ('TESTRAIL_PROJECTID' in process.env && process.env.TESTRAIL_PROJECTID === '') {
delete process.env.TESTRAIL_PROJECTID;
}
registerReportPortalPlugin(on, config);
// eslint-disable-next-line global-require
const grepConfig = require('@cypress/grep/src/plugin')(config);
const result = await cloudPlugin(on, grepConfig);
// eslint-disable-next-line global-require
await require('cypress-testrail-simple/src/plugin')(on, config);
return result;
},
baseUrl: 'https://folio-testing-cypress-diku.ci.folio.org',
testIsolation: false,
},
});