Skip to content

Commit f18a9eb

Browse files
committed
test: add Expo compatibility CI job
1 parent 0e55cbc commit f18a9eb

21 files changed

+15865
-1
lines changed

.github/workflows/ci.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ jobs:
7474
- name: Run integration and browser tests on Deno 2.x only
7575
if: ${{ matrix.deno == '2.x' }}
7676
run: |
77-
npm run test:integration || npm run test:integration
7877
npm run test:integration:browser
7978
8079
- name: Stop Supabase
@@ -101,6 +100,12 @@ jobs:
101100
npm run build
102101
npm run test:integration || npm run test:integration
103102
103+
- name: Run expo compatibility tests
104+
run: |
105+
cd examples/expo-app
106+
npm install
107+
npm run test
108+
104109
- name: Stop Supabase
105110
run: supabase stop
106111

examples/expo-app/.gitignore

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Learn more https://docs.github.com/en/get-started/getting-started-with-git/ignoring-files
2+
3+
# dependencies
4+
node_modules/
5+
6+
# Expo
7+
.expo/
8+
dist/
9+
web-build/
10+
expo-env.d.ts
11+
12+
# Native
13+
.kotlin/
14+
*.orig.*
15+
*.jks
16+
*.p8
17+
*.p12
18+
*.key
19+
*.mobileprovision
20+
21+
# Metro
22+
.metro-health-check*
23+
24+
# debug
25+
npm-debug.*
26+
yarn-debug.*
27+
yarn-error.*
28+
29+
# macOS
30+
.DS_Store
31+
*.pem
32+
33+
# local env files
34+
.env*.local
35+
36+
# typescript
37+
*.tsbuildinfo
38+
39+
app-example
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"editor.codeActionsOnSave": {
3+
"source.fixAll": "explicit",
4+
"source.organizeImports": "explicit",
5+
"source.sortMembers": "explicit"
6+
}
7+
}

examples/expo-app/README.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Welcome to your Expo app 👋
2+
3+
This is an [Expo](https://expo.dev) project created with [`create-expo-app`](https://www.npmjs.com/package/create-expo-app).
4+
5+
## Get started
6+
7+
1. Install dependencies
8+
9+
```bash
10+
npm install
11+
```
12+
13+
2. Start the app
14+
15+
```bash
16+
npx expo start
17+
```
18+
19+
In the output, you'll find options to open the app in a
20+
21+
- [development build](https://docs.expo.dev/develop/development-builds/introduction/)
22+
- [Android emulator](https://docs.expo.dev/workflow/android-studio-emulator/)
23+
- [iOS simulator](https://docs.expo.dev/workflow/ios-simulator/)
24+
- [Expo Go](https://expo.dev/go), a limited sandbox for trying out app development with Expo
25+
26+
You can start developing by editing the files inside the **app** directory. This project uses [file-based routing](https://docs.expo.dev/router/introduction).
27+
28+
## Get a fresh project
29+
30+
When you're ready, run:
31+
32+
```bash
33+
npm run reset-project
34+
```
35+
36+
This command will move the starter code to the **app-example** directory and create a blank **app** directory where you can start developing.
37+
38+
## Learn more
39+
40+
To learn more about developing your project with Expo, look at the following resources:
41+
42+
- [Expo documentation](https://docs.expo.dev/): Learn fundamentals, or go into advanced topics with our [guides](https://docs.expo.dev/guides).
43+
- [Learn Expo tutorial](https://docs.expo.dev/tutorial/introduction/): Follow a step-by-step tutorial where you'll create a project that runs on Android, iOS, and the web.
44+
45+
## Join the community
46+
47+
Join our community of developers creating universal apps.
48+
49+
- [Expo on GitHub](https://github.com/expo/expo): View our open source platform and contribute.
50+
- [Discord community](https://chat.expo.dev): Chat with Expo users and ask questions.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { render, waitFor, cleanup } from '@testing-library/react-native'
2+
import Index from '../app/index.tsx'
3+
4+
describe('Index', () => {
5+
afterEach(() => {
6+
cleanup()
7+
})
8+
9+
it('should display SUBSCRIBED status when realtime connection is established', async () => {
10+
const { getByTestId, unmount } = render(<Index />)
11+
12+
// Initially, the text should be empty
13+
expect(getByTestId('realtime_status')).toHaveTextContent('')
14+
15+
// Wait for the subscription status to be updated
16+
await waitFor(
17+
() => {
18+
expect(getByTestId('realtime_status')).toHaveTextContent('SUBSCRIBED')
19+
},
20+
{
21+
timeout: 2000,
22+
}
23+
)
24+
25+
// Unmount the component to trigger cleanup.
26+
unmount()
27+
})
28+
})

examples/expo-app/app.json

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
"expo": {
3+
"name": "expo-app",
4+
"slug": "expo-app",
5+
"version": "1.0.0",
6+
"orientation": "portrait",
7+
"icon": "./assets/images/icon.png",
8+
"scheme": "expoapp",
9+
"userInterfaceStyle": "automatic",
10+
"newArchEnabled": true,
11+
"ios": {
12+
"supportsTablet": true
13+
},
14+
"android": {
15+
"adaptiveIcon": {
16+
"foregroundImage": "./assets/images/adaptive-icon.png",
17+
"backgroundColor": "#ffffff"
18+
},
19+
"edgeToEdgeEnabled": true
20+
},
21+
"web": {
22+
"bundler": "metro",
23+
"output": "static",
24+
"favicon": "./assets/images/favicon.png"
25+
},
26+
"plugins": [
27+
"expo-router",
28+
[
29+
"expo-splash-screen",
30+
{
31+
"image": "./assets/images/splash-icon.png",
32+
"imageWidth": 200,
33+
"resizeMode": "contain",
34+
"backgroundColor": "#ffffff"
35+
}
36+
]
37+
],
38+
"experiments": {
39+
"typedRoutes": true
40+
}
41+
}
42+
}

examples/expo-app/app/_layout.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { Stack } from 'expo-router'
2+
3+
export default function RootLayout() {
4+
return <Stack />
5+
}

examples/expo-app/app/index.tsx

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import { Text, View } from 'react-native'
2+
import { useState, useEffect } from 'react'
3+
import { createClient } from '@supabase/supabase-js'
4+
5+
const SUPABASE_URL = 'http://127.0.0.1:54321'
6+
const ANON_KEY =
7+
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24iLCJleHAiOjE5ODM4MTI5OTZ9.CRXP1A7WOeoJeXxjNni43kdQwgnWNReilDMblYTn_I0'
8+
9+
const supabase = createClient(SUPABASE_URL, ANON_KEY)
10+
11+
export default function Index() {
12+
const [realtimeStatus, setRealtimeStatus] = useState<string | null>(null)
13+
const channel = supabase.channel('realtime:public:todos')
14+
15+
useEffect(() => {
16+
if (channel.state === 'closed') {
17+
channel.subscribe((status) => {
18+
if (status === 'SUBSCRIBED') setRealtimeStatus(status)
19+
})
20+
}
21+
22+
return () => {
23+
channel.unsubscribe()
24+
supabase.realtime.disconnect()
25+
}
26+
}, [])
27+
28+
return (
29+
<View
30+
style={{
31+
flex: 1,
32+
justifyContent: 'center',
33+
alignItems: 'center',
34+
backgroundColor: '#fff',
35+
}}
36+
>
37+
<Text testID="realtime_status">{realtimeStatus || ''}</Text>
38+
</View>
39+
)
40+
}
91.1 KB
Binary file not shown.
17.1 KB
Loading

0 commit comments

Comments
 (0)