Skip to content

Commit 0eaa85c

Browse files
author
Krzysztof Borowy
committed
appium setup + android test
1 parent 84e053c commit 0eaa85c

File tree

6 files changed

+50
-43
lines changed

6 files changed

+50
-43
lines changed

example/App.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export default function App(): JSX.Element {
7171
<View style={styles.testPickerContainer}>{navigationBar}</View>
7272

7373
<View
74-
testID={`${currentTest.testId}-view`}
74+
accessibilityLabel={`${currentTest.testId}-view`}
7575
key={currentTest.title + iteration}
7676
style={styles.exampleContainer}
7777
>

example/__tests__/asyncstorage.e2e.ts

Lines changed: 0 additions & 30 deletions
This file was deleted.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { commands as cmd } from './commands';
2+
import testCases from '../examples/tests';
3+
4+
describe('Async Storage', () => {
5+
describe('functional tests', () => {
6+
it('should be visible', async () => {
7+
const el = await cmd.elementByLabel('functional-view');
8+
await expect(await el.isExisting()).toEqual(true);
9+
});
10+
11+
const testNames = Object.keys(testCases);
12+
for (const name of testNames) {
13+
it(`${name}`, async () => {
14+
const el = await cmd.elementByLabel(`test:${name}`);
15+
await expect(await el.getText()).toEqual('Pass');
16+
});
17+
}
18+
19+
// Re-run tests with native delegate set
20+
for (const currentName of testNames) {
21+
const name = currentName + ' with delegate';
22+
it(`${name}`, async () => {
23+
const el = await cmd.elementByLabel(`test:${name}`);
24+
const label = await el.getText();
25+
if (label === 'Skip') {
26+
return;
27+
}
28+
29+
expect(label).toEqual('Pass');
30+
});
31+
}
32+
});
33+
});

example/__tests__/commands.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { e2e } from '../jest.setup';
2+
3+
const testAppId = 'com.microsoft.reacttestapp';
4+
5+
export const commands = {
6+
restartApp: async () => {
7+
await e2e.terminateApp(testAppId);
8+
await e2e.activateApp(testAppId);
9+
},
10+
elementByLabel: async (id: string) => await e2e.$(`~${id}`),
11+
elementByLabelBy: async (id: string) => await e2e.$(`aria/${id}`),
12+
};

example/examples/Functional.tsx

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -141,11 +141,7 @@ function Functional(): JSX.Element {
141141
return (
142142
<View key={name} style={styles.passed}>
143143
<Text style={styles.testLabel}>{name}</Text>
144-
<Text
145-
accessibilityLabel="Pass"
146-
testID={testID}
147-
style={styles.testResult}
148-
>
144+
<Text accessibilityLabel={testID} style={styles.testResult}>
149145
Pass
150146
</Text>
151147
</View>
@@ -156,11 +152,7 @@ function Functional(): JSX.Element {
156152
return (
157153
<View key={name} style={styles.skipped}>
158154
<Text style={styles.testLabel}>{name}</Text>
159-
<Text
160-
accessibilityLabel="Skip"
161-
testID={testID}
162-
style={styles.testResult}
163-
>
155+
<Text accessibilityLabel={testID} style={styles.testResult}>
164156
Skip
165157
</Text>
166158
</View>
@@ -170,7 +162,7 @@ function Functional(): JSX.Element {
170162
return (
171163
<View key={name} style={styles.failed}>
172164
<Text style={styles.testLabel}>{name}</Text>
173-
<View accessibilityLabel="Fail" testID={testID}>
165+
<View accessibilityLabelledBy="Fail" accessibilityLabel={testID}>
174166
<Text style={styles.testResult}>{`Step: ${
175167
result.step + 1
176168
}`}</Text>

example/jest.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const config: JestConfig = {
77
bail: 0,
88
rootDir: '..',
99
setupFilesAfterEnv: ['./example/jest.setup.ts'],
10-
testMatch: ['**/?(*.)e2e.ts(x)?'],
10+
testMatch: ['**/?(*.)spec.ts(x)?'],
1111
moduleNameMapper: {
1212
'^uuid$': '<rootDir>/node_modules/uuid/wrapper.mjs',
1313
},

0 commit comments

Comments
 (0)