-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathwdio.conf.js
More file actions
99 lines (87 loc) · 2.58 KB
/
wdio.conf.js
File metadata and controls
99 lines (87 loc) · 2.58 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
const browserstack = require('browserstack-local')
const request = require('request')
const errors = []
const user = process.env.BROWSERSTACK_USERNAME || 'BROWSERSTACK_USERNAME'
const key = process.env.BROWSERSTACK_ACCESS_KEY || 'BROWSERSTACK_ACCESS_KEY'
exports.config = {
debug: process.env.CI ? false : true,
user,
key,
updateJob: false,
specs: [
'./__tests__/ui/*-tests.js',
],
exclude: [],
maxInstances: 2,
capabilities: [{
browser: 'chrome',
name: 'chrome_tests',
build: process.env.CI ?
'hypermedia-client #' + process.env.TRAVIS_BUILD_NUMBER :
'hypermedia-client-local',
'browserstack.local': true,
}, {
browser: 'firefox',
name: 'firefox_tests',
build: process.env.CI ?
'hypermedia-client #' + process.env.TRAVIS_BUILD_NUMBER :
'hypermedia-client-local',
'browserstack.local': true,
}],
logLevel: 'silent',
coloredLogs: true,
screenshotPath: './errorShots/',
baseUrl: 'http://localhost:3004',
waitforTimeout: 30000,
connectionRetryTimeout: 90000,
connectionRetryCount: 3,
framework: 'mocha',
mochaOpts: {
ui: 'bdd',
timeout: 30000,
},
// Code to start browserstack local before start of test
onPrepare: (config, capabilities) => {
if (process.env.CI) {
console.log('On CI. Skipping local connection because Travis CI will handle this.')
return
}
console.log('Connecting local')
return new Promise((resolve, reject) => {
exports.bs_local = new browserstack.Local()
exports.bs_local.start({'key': exports.config.key, 'force': true }, error => {
if (error) {
console.log(error)
return reject(error)
}
console.log('Connected. Now testing...')
resolve()
})
})
},
afterTest: test => {
if (!test.passed) {
errors.push(`${test.fullTitle} failed with error: '${test.err.message}'`)
}
},
after: (result, capabilities, specs) => {
if (result != 0) {
console.log('Failing session with id: ' + browser.sessionId)
request({
uri: `https://${user}:${key}@www.browserstack.com/automate/sessions/${browser.sessionId}.json`,
method:'PUT',
form:{ 'status':'error','reason': errors.join(' | ') },
})
}
},
// Code to stop browserstack local after end of test
onComplete: (exitCode, config, capabilities) => {
console.log('Exited with code: ' + exitCode)
if (process.env.CI) {
console.log('On CI. No local connection to close.')
return
}
console.log('Closing local connection')
exports.bs_local.stop(() => {})
},
}