-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwdio.conf.js
executable file
·110 lines (97 loc) · 3.56 KB
/
wdio.conf.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
/* global testName, eyes, configuration */
const cucumberJson = require('wdio-cucumberjs-json-reporter').default;
const testApproach = process.argv[6];
exports.config = {
capabilities: [{ browserName: 'chrome' }],
maxInstances: 5,
specs: [`./tests/features/*.feature`],
logLevel: 'error',
bail: 0,
baseUrl: process.argv[4],
waitforTimeout: 10000,
connectionRetryTimeout: 90000,
connectionRetryCount: 3,
specFileRetries: 0,
framework: 'cucumber',
reporters: [['cucumberjs-json', { jsonFolder: './report/' }]],
cucumberOpts: {
require: [`./tests/steps/${testApproach}/*.steps.js`],
failFast: false,
format: ['pretty'],
colors: true,
snippets: true,
source: true,
strict: false,
tagsInTitle: false,
timeout: 60000,
ignoreUndefinedDefinitions: false,
failAmbiguousDefinitions: true,
},
services: [['selenium-standalone']],
beforeSession() {
require('@babel/register');
},
before(capabilities, specs) {
// eslint-disable-next-line prefer-destructuring
global.testName = specs[0].split('/').slice(-1)[0];
global.loginURL = browser.options.baseUrl;
global.elements = require('./tests/data/elements.json');
global.assert = require('chai').assert;
global.reporter = require('wdio-cucumberjs-json-reporter').cucumberJson;
browser.setWindowSize(1200, 800);
// When using visual AI Tests appraoch
if (testApproach === 'visualAITests') {
const {
ClassicRunner,
Eyes,
} = require('@applitools/eyes-webdriverio');
global.Target = require('@applitools/eyes-webdriverio').Target;
const { Configuration } = require('@applitools/eyes-selenium');
const runner = new ClassicRunner();
global.configuration = new Configuration();
configuration.setAppName('Applitools Hackathon');
configuration.setTestName(testName);
global.eyes = new Eyes(runner);
eyes.setApiKey(process.env.APPLITOOLS_API_KEY);
eyes.setConfiguration(configuration);
eyes.setForceFullPageScreenshot(true);
eyes.setBatch('Applitools Hackathon Tests', 'All Tests');
}
},
async beforeScenario(uri, feature, scenario) {
// When using visual AI Tests appraoch
if (testApproach === 'visualAITests') {
configuration.setTestName(`${testName}-${scenario.name}`);
await eyes.open(browser);
}
},
afterStep(uri, feature, result) {
if (!result.passed)
cucumberJson.attach(browser.takeScreenshot(), 'image/png');
},
async afterScenario() {
// When using visual AI Tests appraoch
if (testApproach === 'visualAITests') {
await eyes.closeAsync();
}
},
async after() {
// When using visual AI Tests appraoch
if (testApproach === 'visualAITests') {
await eyes.abortIfNotClosed();
}
},
onComplete() {
const report = require('multiple-cucumber-html-reporter');
report.generate({
jsonDir: './report/',
reportPath: './report/',
openReportInBrowser: true,
pageTitle: 'Applitools Hackathon Tests',
pageFooter:
'<div><p>       A report for Applitools Hackathon Tests</p></div>',
durationInMS: true,
reportName: 'Applitools Hackathon Tests Report',
});
},
};