You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Capacitor package uses Vitest browser mode with a custom provider. Vitest starts a browser test server, then the provider runs the example Capacitor app and points the app at that server.
6
+
7
+
Build the workspace before running these tests so the Capacitor package can resolve generated workspace package outputs:
8
+
9
+
```sh
10
+
pnpm install
11
+
pnpm build:packages
12
+
cd packages/capacitor/example-app
13
+
pnpm install
14
+
cd ..
15
+
```
16
+
17
+
The test provider reads these environment variables:
18
+
19
+
-`TEST_PLATFORM`: Native platform to run. Use `ios` or `android`.
20
+
-`TEST_TARGET`: Simulator/emulator target id passed to `cap run --target`.
21
+
-`TEST_SERVER_HOST`: Hostname the native app should use to reach the Vitest server. Android defaults to `10.0.2.2`; iOS uses the Vitest URL host as-is.
22
+
23
+
### iOS
24
+
25
+
List available iOS simulator targets:
26
+
27
+
```sh
28
+
cd packages/capacitor/example-app
29
+
pnpm exec cap run ios --list
30
+
```
31
+
32
+
Run the integration tests on a simulator:
33
+
34
+
```sh
35
+
cd packages/capacitor
36
+
TEST_PLATFORM=ios \
37
+
TEST_TARGET=<ios-simulator-id> \
38
+
pnpm exec vitest run --config vitest.config.ts
39
+
```
40
+
41
+
### Android
42
+
43
+
List available Android emulator/device targets:
44
+
45
+
```sh
46
+
adb devices
47
+
```
48
+
49
+
For the default Android emulator, the target is usually `emulator-5554`.
50
+
51
+
Run the integration tests on Android:
52
+
53
+
```sh
54
+
cd packages/capacitor
55
+
TEST_PLATFORM=android \
56
+
TEST_TARGET=emulator-5554 \
57
+
pnpm exec vitest run --config vitest.config.ts
58
+
```
59
+
60
+
Android defaults `TEST_SERVER_HOST` to `10.0.2.2`, which lets the emulator reach the host machine without `adb reverse`. The Vitest config also binds the test server to `0.0.0.0` for this reason.
This app was created using [`@capacitor/create-app`](https://github.com/ionic-team/create-capacitor-app),
4
-
and comes with a very minimal shell for building an app.
3
+
This app is a minimal Capacitor host for the `@powersync/capacitor` package. It is used as the native app shell for the package's Vitest browser integration tests: Vitest starts a browser test server, then the custom provider launches this app and points the WebView at that server.
5
4
6
-
### Running this example
5
+
The `ios/` and `android/` folders are committed intentionally. Capacitor treats them as app source folders, and they contain native configuration such as `Info.plist`, `AndroidManifest.xml`, plugin setup, and platform-specific project files.
7
6
8
-
To run the provided example, you can use `npm start` command.
7
+
## Refresh Native Projects
8
+
9
+
After changing Capacitor config, native dependencies, or plugin setup, refresh the native projects:
9
10
10
11
```bash
11
-
npm start
12
+
pnpm exec cap sync ios
13
+
pnpm exec cap sync android
12
14
```
15
+
16
+
See `../DEVELOP.md` for the full native integration test workflow.
0 commit comments