Skip to content

Commit 84e053c

Browse files
author
Krzysztof Borowy
committed
initial appium setup
1 parent f4e5d92 commit 84e053c

File tree

12 files changed

+3623
-502
lines changed

12 files changed

+3623
-502
lines changed

example/__tests__/App.js

Lines changed: 0 additions & 157 deletions
This file was deleted.

example/__tests__/asyncstorage.e2e.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
describe('Async Storage', () => {
2+
describe('functional tests', () => {
3+
it('should pass', () => {
4+
expect(2).toEqual(3);
5+
});
6+
// it('should be visible', async () => {
7+
// await expect(element(by.id('functional-view'))).toExist();
8+
// });
9+
//
10+
// const testNames = Object.keys(tests);
11+
// for (const name of testNames) {
12+
// it(name, async () => {
13+
// await expect(element(by.id(`test:${name}`))).toHaveLabel('Pass');
14+
// });
15+
// }
16+
//
17+
// // Re-run tests with native delegate set
18+
// for (const currentName of testNames) {
19+
// const name = currentName + ' with delegate';
20+
// it(name, async () => {
21+
// const el = await element(by.id(`test:${name}`)).getAttributes();
22+
// if (el.label === 'Skip') {
23+
// return;
24+
// }
25+
//
26+
// await expect(element(by.id(`test:${name}`))).toHaveLabel('Pass');
27+
// });
28+
// }
29+
});
30+
});

example/android/app/src/androidTest/java/com/microsoft/reacttestapp/DetoxTest.java

Lines changed: 0 additions & 30 deletions
This file was deleted.

example/appium.config.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
module.exports = {
2+
server: {
3+
address: '127.0.0.1',
4+
'callback-address': '127.0.0.1',
5+
'callback-port': 4723,
6+
port: 4723,
7+
},
8+
};

example/e2e/asyncstorage.e2e.js

Lines changed: 0 additions & 42 deletions
This file was deleted.

example/jest.config.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// eslint-disable-next-line jest/no-jest-import
2+
import { Config as JestConfig } from 'jest';
3+
4+
const config: JestConfig = {
5+
preset: 'react-native',
6+
testTimeout: 60000,
7+
bail: 0,
8+
rootDir: '..',
9+
setupFilesAfterEnv: ['./example/jest.setup.ts'],
10+
testMatch: ['**/?(*.)e2e.ts(x)?'],
11+
moduleNameMapper: {
12+
'^uuid$': '<rootDir>/node_modules/uuid/wrapper.mjs',
13+
},
14+
};
15+
16+
export default config;

example/jest.setup.js

Lines changed: 0 additions & 7 deletions
This file was deleted.

example/jest.setup.ts

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import { remote, RemoteOptions } from 'webdriverio';
2+
3+
jest.retryTimes(3);
4+
5+
const Capabilities = {
6+
android: {
7+
platformName: 'Android',
8+
'appium:deviceName': 'Android Emulator',
9+
'appium:app':
10+
'example/android/app/build/outputs/apk/release/app-release.apk',
11+
'appium:automationName': 'UiAutomator2',
12+
'appium:newCommandTimeout': 240,
13+
},
14+
ios: {},
15+
};
16+
17+
let client: WebdriverIO.Browser;
18+
19+
function getDriverConfig(platform: string | undefined) {
20+
if (!platform || (platform !== 'android' && platform !== 'ios')) {
21+
throw Error(
22+
`Unrecognized platform passed from E2E_PLATFORM env: ${platform}`
23+
);
24+
}
25+
26+
const config: RemoteOptions = {
27+
port: 4723,
28+
waitforTimeout: 60000,
29+
logLevel: 'error',
30+
capabilities: Capabilities[platform],
31+
};
32+
33+
return config;
34+
}
35+
36+
beforeAll(async () => {
37+
const platform = process.env['E2E_PLATFORM'];
38+
const config = getDriverConfig(platform);
39+
client = await remote(config);
40+
});
41+
42+
afterAll(async () => {
43+
await client.deleteSession();
44+
});
45+
46+
export { client as e2e };

package.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,15 @@
7272
"@react-native-community/eslint-config": "^3.0.0",
7373
"@semantic-release/changelog": "^6.0.0",
7474
"@semantic-release/git": "^10.0.0",
75+
"@types/jest": "^29.5.2",
7576
"@types/lodash": "^4.14.184",
7677
"@types/react": "^18.0.0",
78+
"appium": "2.0.0-rc.3",
79+
"appium-uiautomator2-driver": "^2.26.2",
7780
"concurrently": "^6.4.0",
7881
"eslint": "^8.0.0",
7982
"expo": "^48.0.0",
80-
"jest": "^29.2.1",
81-
"jest-circus": "^29.2.1",
83+
"jest": "^29.5.0",
8284
"lodash": "^4.17.21",
8385
"prettier": "^2.5.1",
8486
"react": "18.2.0",
@@ -91,7 +93,8 @@
9193
"react-native-windows": "^0.71.0",
9294
"react-test-renderer": "18.2.0",
9395
"semantic-release": "^19.0.0",
94-
"typescript": "^4.9.4"
96+
"typescript": "^4.9.4",
97+
"webdriverio": "^8.11.2"
9598
},
9699
"packageManager": "yarn@3.4.1",
97100
"resolutions": {
@@ -104,15 +107,12 @@
104107
"metro-react-native-babel-transformer": "^0.73.10",
105108
"metro-runtime": "^0.73.10",
106109
"metro-source-map": "^0.73.10",
107-
"npm/chalk": "^4.1.2"
108-
},
109-
"jest": {
110-
"preset": "react-native",
111-
"setupFiles": [
112-
"./example/jest.setup.js"
113-
]
110+
"chalk": "4.1.2",
111+
"uuid": "^9.0.0",
112+
"ts-node": "^10.9.1"
114113
},
115114
"eslintConfig": {
115+
"root": true,
116116
"extends": [
117117
"@react-native-community",
118118
"plugin:jest/recommended"

0 commit comments

Comments
 (0)