Skip to content

Commit bf91d0d

Browse files
author
Krzysztof Borowy
authored
test: Setup E2E (#979)
* initial appium setup * appium setup + android test * ios * ios working * run e2e * wdio runner * disable e2e on ci * docs * last touches * last touches for real
1 parent ab1717c commit bf91d0d

File tree

23 files changed

+5041
-1627
lines changed

23 files changed

+5041
-1627
lines changed

.github/Brewfile.ios

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

.github/workflows/ci.yml

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
- name: Set up Node.js
1818
uses: actions/[email protected]
1919
with:
20-
node-version: 16
20+
node-version: 18.16.1
2121
cache: yarn
2222
- name: Install JS dependencies
2323
run: yarn
@@ -32,17 +32,21 @@ jobs:
3232
- name: Set up Node.js
3333
uses: actions/[email protected]
3434
with:
35-
node-version: 16
35+
node-version: 18.16.1
3636
cache: yarn
3737
- name: Install JS dependencies
3838
run: |
3939
yarn
4040
- name: Test Next Storage
41-
uses: gradle/gradle-build-action@v2.4.2
41+
uses: gradle/gradle-build-action@v2
4242
with:
4343
gradle-version: wrapper
4444
arguments: react-native-async-storage_async-storage:test
4545
build-root-directory: example/android
46+
- name: Build e2e binary
47+
run: |
48+
yarn build:e2e:android
49+
4650
ios:
4751
name: iOS
4852
runs-on: macos-latest
@@ -58,32 +62,22 @@ jobs:
5862
- name: Set up Node.js
5963
uses: actions/[email protected]
6064
with:
61-
node-version: 16
65+
node-version: 18.16.1
6266
cache: yarn
63-
- name: Set up environment
64-
run: |
65-
brew bundle --file=.github/Brewfile.ios --no-lock
66-
touch .watchmanconfig
6767
- name: Install JS dependencies
6868
run: |
6969
yarn
7070
- name: Bundle JS
7171
run: |
72-
yarn bundle:ios --dev false
72+
yarn bundle:ios
7373
- name: Install Pods
7474
run: |
7575
RCT_NEW_ARCH_ENABLED=1 pod install
7676
working-directory: example/ios
77-
- name: Boot simulator
78-
run: |
79-
./scripts/ios_e2e.sh 'run_simulator'
80-
- name: Build
77+
- name: Build e2e binary
8178
run: |
8279
yarn build:e2e:ios
83-
- name: Test
84-
if: false
85-
run: |
86-
yarn test:e2e:ios
80+
8781
macos:
8882
name: macOS
8983
runs-on: macos-latest
@@ -99,7 +93,7 @@ jobs:
9993
- name: Set up Node.js
10094
uses: actions/[email protected]
10195
with:
102-
node-version: 16
96+
node-version: 18.16.1
10397
cache: yarn
10498
- name: Install JS dependencies
10599
run: |
@@ -118,6 +112,7 @@ jobs:
118112
if: false
119113
run: |
120114
yarn test:e2e:macos
115+
121116
windows:
122117
name: Windows
123118
runs-on: windows-2022
@@ -131,7 +126,7 @@ jobs:
131126
- name: Set up Node.js
132127
uses: actions/[email protected]
133128
with:
134-
node-version: 16
129+
node-version: 18.16.1
135130
cache: yarn
136131
- name: Install JS dependencies
137132
run: |
@@ -142,6 +137,7 @@ jobs:
142137
- name: Build
143138
run: |
144139
yarn react-native run-windows --release --arch x64 --logging --no-packager --no-launch --no-deploy --msbuildprops "BundleEntryFile=index.ts" --no-telemetry
140+
145141
release:
146142
name: Release
147143
needs: [review, android, ios, macos, windows]
@@ -155,7 +151,7 @@ jobs:
155151
- name: Set up Node.js
156152
uses: actions/[email protected]
157153
with:
158-
node-version: 16
154+
node-version: 18.16.1
159155
cache: yarn
160156
- name: Install JS dependencies
161157
run: |

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,28 @@ An asynchronous, unencrypted, persistent, key-value storage system for React Nat
1717
Head over to [documentation](https://react-native-async-storage.github.io/async-storage/docs/install) to learn more.
1818

1919

20+
## Running E2E locally
21+
22+
### Android
23+
24+
1. Create and start Android Emulator with Play services, API level 29
25+
2. Build app and run tests
26+
```shell
27+
yarn bundle:android
28+
yarn build:e2e:android
29+
yarn test:e2e:android
30+
```
31+
32+
### iOS
33+
34+
1. Create and start iPhone 14 simulator with iOS version 16.4
35+
2. Build app and run tests
36+
```shell
37+
yarn bundle:ios
38+
yarn build:e2e:ios
39+
yarn test:e2e:ios
40+
```
41+
2042
## Contribution
2143
Pull requests are welcome. Please open an issue first to discuss what you would like to change.
2244

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__/App.js

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

example/__tests__/android.conf.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { config as commonConfig } from './common.conf';
2+
3+
export const config: WebdriverIO.Config = {
4+
...commonConfig,
5+
capabilities: [
6+
{
7+
platformName: 'Android',
8+
maxInstances: 1,
9+
'appium:deviceName': 'Android Emulator',
10+
'appium:app':
11+
'example/android/app/build/outputs/apk/release/app-release.apk',
12+
'appium:automationName': 'UiAutomator2',
13+
'appium:newCommandTimeout': 240,
14+
'appium:appWaitActivity':
15+
'com.microsoft.reacttestapp.component.ComponentActivity',
16+
},
17+
],
18+
};
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { commands as cmd } from './commands';
2+
import testCases from '../examples/tests';
3+
4+
describe('Async Storage functional tests', () => {
5+
it('should be visible', async () => {
6+
// wait until content loads, as android's waitForSelectorTimeout setting does not seem to work
7+
await new Promise((r) => setTimeout(r, 3000));
8+
const el = await cmd.elementByLabel('functional-view');
9+
await expect(await el.isExisting()).toEqual(true);
10+
});
11+
12+
const testNames = Object.keys(testCases);
13+
describe('storing / reading values', () => {
14+
for (const name of testNames) {
15+
it(name, async () => {
16+
const el = await cmd.elementByLabel(`test:${name}`);
17+
await expect(await el.getText()).toEqual('Pass');
18+
});
19+
}
20+
});
21+
22+
describe('storing / reading values with delegate', () => {
23+
for (const currentName of testNames) {
24+
const name = currentName + ' with delegate';
25+
it(name, async () => {
26+
const el = await cmd.elementByLabel(`test:${name}`);
27+
const label = await el.getText();
28+
if (label === 'Skip') {
29+
return;
30+
}
31+
32+
expect(label).toEqual('Pass');
33+
});
34+
}
35+
});
36+
});

example/__tests__/commands.ts

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

0 commit comments

Comments
 (0)