-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcypress.config.ts
More file actions
99 lines (94 loc) · 3.37 KB
/
Copy pathcypress.config.ts
File metadata and controls
99 lines (94 loc) · 3.37 KB
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
import { verifyDownloadTasks } from 'cy-verify-downloads'
import { defineConfig } from 'cypress'
const { lighthouse, prepareAudit } = require("@cypress-audit/lighthouse")
const fs = require('fs-extra')
const xlsx = require('xlsx')
const xml2js = require('xml2js')
const http = require('http')
const https = require('https')
export default defineConfig({
chromeWebSecurity: false,
modifyObstructiveCode: false,
pageLoadTimeout: 100000,
defaultCommandTimeout: 50000,
video: false,
trashAssetsBeforeRuns: true,
viewportWidth: 1300,
viewportHeight: 800,
watchForFileChanges: false,
numTestsKeptInMemory: 0,
experimentalMemoryManagement: true,
reporter: 'mochawesome',
reporterOptions: {
reportDir: 'cypress/results',
overwrite: false,
html: false,
timestamp: 'mmddyyyy_HHMMss',
json: true,
inline: true,
},
screenshotsFolder: 'mochawesome-report/assets',
e2e: {
// We've imported your old cypress plugins here.
// You may want to clean this up later by importing these.
setupNodeEvents(on, config) {
on("before:browser:launch", (browser = Cypress.browser, launchOptions) => {
prepareAudit(launchOptions);
if (browser.family === 'chromium' && browser.name !== 'electron') {
launchOptions.args.push('--disable-dev-shm-usage')
launchOptions.args.push('--js-flags=--max-old-space-size=4096')
launchOptions.args.push('--disable-gpu')
}
return launchOptions
})
on('task', verifyDownloadTasks)
on('task', {
readXlsx({file, sheet}) {
const buf = fs.readFileSync(file);
const workbook = xlsx.read(buf, {type:'buffer'})
const rows = xlsx.utils.sheet_to_json(workbook.Sheets[sheet])
return rows
},
readFileSafe(filePath: string) {
try {
if (fs.existsSync(filePath)) {
const content = fs.readFileSync(filePath, 'utf8')
return content || null
}
return null
} catch {
return null
}
},
parseXML(xmlContent: string) {
return new Promise((resolve, reject) => {
const parser = new xml2js.Parser()
parser.parseString(xmlContent, (err: any, result: any) => {
if (err) reject(err)
else resolve(result)
})
})
},
checkUrl(url: string) {
const lib = url.startsWith('https') ? https : http
return new Promise((resolve) => {
const req = lib.get(url, { timeout: 30000 }, (res: any) => {
// Consume response data to free up memory
res.resume()
resolve({ reachable: true, statusCode: res.statusCode })
})
req.on('error', (err: any) => {
resolve({ reachable: false, error: err.message || String(err) })
})
req.on('timeout', () => {
req.destroy()
resolve({ reachable: false, error: 'ETIMEDOUT' })
})
})
}
})
return require('./cypress/plugins/index.js')(on, config)
},
baseUrl: 'https://dev-madie.hcqis.org',
},
})