Skip to content

Commit 9703aa7

Browse files
committed
test: add Expo compatibility CI job
1 parent d24da55 commit 9703aa7

21 files changed

+15873
-2
lines changed

.github/workflows/ci.yml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,24 @@ jobs:
7878
run: |
7979
supabase start
8080
81-
- name: Run tests
81+
- name: Prepare integration tests
8282
run: |
8383
npm clean-install
84-
npm run test:integration || npm run test:integration
84+
85+
- name: Run integration tests
86+
run: |
87+
npm run test:integration || npm run test:integration:browser
88+
89+
- name: Run browser integration tests
90+
run: |
8591
npm run test:integration:browser
8692
93+
- name: Run expo compatibility tests
94+
run: |
95+
cd examples/expo-app
96+
npm install
97+
npm run test
98+
8799
- name: Stop Supabase
88100
run: |
89101
supabase stop

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+
}
Binary file not shown.
Loading
1.43 KB
Loading
21.9 KB
Loading
Loading
6.19 KB
Loading
Loading
Loading
17.1 KB
Loading

examples/expo-app/eslint.config.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// https://docs.expo.dev/guides/using-eslint/
2+
const { defineConfig } = require('eslint/config')
3+
const expoConfig = require('eslint-config-expo/flat')
4+
5+
module.exports = defineConfig([
6+
expoConfig,
7+
{
8+
ignores: ['dist/*'],
9+
},
10+
])

0 commit comments

Comments
 (0)