-
Notifications
You must be signed in to change notification settings - Fork 0
/
cypress.config.js
84 lines (77 loc) · 2.58 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
const { defineConfig } = require('cypress');
const createBundler = require('@bahmutov/cypress-esbuild-preprocessor');
const preprocessor = require('@badeball/cypress-cucumber-preprocessor');
const createEsbuildPlugin = require('@badeball/cypress-cucumber-preprocessor/esbuild');
const {
beforeRunHook,
afterRunHook
} = require('cypress-mochawesome-reporter/lib');
const path = require('path');
const { mergeFiles } = require('junit-report-merger');
const fs = require('fs');
const reportDir = path.join(__dirname, 'cypress', 'reports');
const junitReportsRegex = /results-.*\.xml/;
async function setupNodeEvents(on, config) {
await preprocessor.addCucumberPreprocessorPlugin(on, config);
on(
'file:preprocessor',
createBundler({
plugins: [createEsbuildPlugin.default(config)]
})
);
on('before:run', async (details) => {
await beforeRunHook(details);
});
on('after:run', async () => {
await afterRunHook();
// Merge all the junit xmls
const outputFile = path.join(reportDir, 'combined-junit-report.xml');
const inputFiles = [
path.posix.join('cypress', 'reports', 'results-*.xml')
];
mergeFiles(outputFile, inputFiles).then(() => {
// Remove all the junit xmls
fs.readdirSync(reportDir)
.filter((f) => junitReportsRegex.test(f))
.map((f) => fs.unlinkSync(path.join(reportDir, f)));
});
});
return config;
}
module.exports = defineConfig({
e2e: {
specPattern: '**/*.feature',
experimentalRunAllSpecs: true,
setupNodeEvents
},
env: {
tags: ['not @Smoke']
},
watchForFileChanges: false,
chromeWebSecurity: false,
viewportWidth: 1920,
viewportHeight: 1080,
reporter: 'cypress-multi-reporters',
reporterOptions: {
reporterEnabled: 'cypress-mochawesome-reporter, mocha-junit-reporter',
cypressMochawesomeReporterReporterOptions: {
reportDir: reportDir,
charts: true,
reportPageTitle: 'Cypress Automation - Learning',
embeddedScreenshots: true,
inlineAssets: true,
quite: true,
overwrite: true,
html: false,
code: false
},
mochaJunitReporterReporterOptions: {
mochaFile: path.join(reportDir, 'results-[hash].xml'),
toConsole: true
}
},
embeddedScreenshots: true,
screenshotOnRunFailure: true,
screenshotsFolder: path.join(reportDir, 'screenshots'),
video: false
});