-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtest.js
80 lines (74 loc) · 2.27 KB
/
test.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
'use strict';
var assert = require('assert');
var run = require('./');
var USER = 'then-jsonp';
var ACCESS_KEY = 'beb60500-a585-440c-82e9-0888d716570d';
run(__dirname + '/empty.js', 'chromedriver', {
name: 'local-tests',
testComplete: 'return true;',
testPassed: 'return true;'
}).then(function (result) {
assert(result.passed === true);
console.dir(result);
return run.runTestsAtLocation({url: 'http://example.com'}, 'chromedriver', {
name: 'custom-tests',
testComplete: () => Promise.resolve(true),
testPassed: (cabbie) => {
return cabbie.getSyncDriver().then(driver => {
const window = driver.browser().activeWindow();
const title = window.getElement('h1');
assert(title.isDisplayed() === true);
assert(title.getText().trim() === 'Example Domain');
return true;
}).catch(ex => {
console.error(ex.stack);
return false;
});
}
})
}).then(function (result) {
assert(result.passed === true);
console.dir(result);
return run(__dirname + '/empty.js', 'saucelabs', {
username: USER,
accessKey: ACCESS_KEY,
testComplete: 'return true;',
testPassed: 'return true;',
filterPlatforms: function (platform) {
return platform.browserName === 'chrome' && platform.version === '34';
},
bail: true,
timeout: '15s'
});
}).then(function (results) {
assert(results.passed === true);
console.dir(results);
return run(__dirname + '/empty.js', 'saucelabs', {
username: USER,
accessKey: ACCESS_KEY,
testComplete: 'return true;',
testPassed: 'return true;',
filterPlatforms: function (platform, defaultFilter) {
return platform.browserName === 'chrome' && defaultFilter(platform);
},
bail: true,
timeout: '15s'
});
}).then(function (results) {
assert(results.passed === true);
console.dir(results);
return run(__dirname + '/empty.js', 'saucelabs', {
username: USER,
accessKey: ACCESS_KEY,
testComplete: 'return true;',
testPassed: 'return false;',
filterPlatforms: function (platform, defaultFilter) {
return platform.browserName === 'chrome' && defaultFilter(platform);
},
bail: true,
timeout: '15s'
});
}).done(function (results) {
assert(results.passed === false);
console.dir(results);
});