forked from nightwatchjs/nightwatch
/
testAppiumAPI.js
66 lines (59 loc) · 1.55 KB
/
testAppiumAPI.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
const {strictEqual} = require('assert');
const path = require('path');
const common = require('../../../common.js');
const MockServer = require('../../../lib/mockserver.js');
const NightwatchClient = common.require('index.js');
describe('appium api demos', function () {
beforeEach(function (done) {
this.server = MockServer.init(undefined, {port: 4723});
this.server.on('listening', () => {
done();
});
});
afterEach(function (done) {
this.server.close(function () {
done();
});
});
it('run appium api demo tests basic', function () {
const testsPath = path.join(__dirname, '../../../apidemos/appium/appiumTest.js');
const globals = {
waitForConditionPollInterval: 50,
reporter(results) {
if (results.lastError) {
throw results.lastError;
}
}
};
MockServer.addMock({
url: '/wd/hub/session',
method: 'POST',
response: JSON.stringify({
value: {
sessionId: '1352110219202',
version: 'TEST',
platform: 'TEST'
}
})
});
return NightwatchClient.runTests(testsPath, {
selenium: {
host: 'localhost',
port: 4723,
start_process: false,
use_appium: true
},
desiredCapabilities: {
browserName: ''
},
output: false,
skip_testcases_on_fail: false,
silent: true,
persist_globals: true,
globals,
output_folder: false
}).then(_ => {
strictEqual(NightwatchClient.app !== undefined, true);
});
});
});