Skip to content

Commit b393d68

Browse files
grdsdevgeorgRusanovgeorgiy.rusanovfilipecabacohf
authored
test: add Expo compatibility CI job (#1432)
* test: add Expo compatibility CI job * ignore examples on tests * run expo test twice * update expo deps * increase timeout * add timeout * wip * make sure to run expo tests against local supabase * Expo ci fix (#1465) * try to fix ci * trying to fix expo job * buils and test in one step * fix * another try * check realtime * another try * debug * debug * debug * debug * more logs * looking the problem with realtime * more logs * more logs * debug * wait for Tenant realtime-dev * use real ws in expo * real ws * deleted all logging * trying universal * deleted universal --------- Co-authored-by: georgiy.rusanov <[email protected]> * fix: bump realtime-js # Conflicts: # package-lock.json # package.json * fix: bump up realtime (#1443) * fix: bump realtime-js (#1453) * merge next into master (#1438) * fix: bump realtime-js * fix: bump up realtime (#1443) --------- Co-authored-by: Filipe Cabaço <[email protected]> * Next (#1444) * fix: bump realtime-js * fix: bump up realtime (#1443) --------- Co-authored-by: Guilherme Souza <[email protected]> * fix: bump up realtime (#1446) * fix: bump realtime-js * fix: bump up realtime --------- Co-authored-by: Guilherme Souza <[email protected]> * feat: bump auth-js to v2.70.0 (#1449) * fix: update realtime-js --------- Co-authored-by: Filipe Cabaço <[email protected]> Co-authored-by: Stojan Dimitrovski <[email protected]> * bump realtime-js * fix: bump realtime-js (#1456) * fix: bump realtime-js * fix: bump realtime-js to 2.11.11-next.5 * fix: update realtime-js to 2.11.12-next.1 * fix rebase * revert expo test * fix * revert realtime-js * ignore examples * rename to TEST_ANON_KEY * move expo inside test * fix path * fix --------- Co-authored-by: georgRusanov <[email protected]> Co-authored-by: georgiy.rusanov <[email protected]> Co-authored-by: Filipe Cabaço <[email protected]> Co-authored-by: Stojan Dimitrovski <[email protected]>
1 parent 0e55cbc commit b393d68

26 files changed

+15894
-9
lines changed

.github/workflows/ci.yml

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
node-version: ${{ matrix.node }}
3333

3434
- run: npm clean-install
35-
35+
3636
- name: Type Check
3737
run: npm run test:types
3838

@@ -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
@@ -103,7 +102,7 @@ jobs:
103102
104103
- name: Stop Supabase
105104
run: supabase stop
106-
105+
107106
next-integration:
108107
name: Next.js Integration
109108
runs-on: ubuntu-latest
@@ -127,7 +126,37 @@ jobs:
127126
cd test/integration/next
128127
npm install
129128
npx playwright install
130-
npm run test
129+
npm run test
130+
131+
- name: Stop Supabase
132+
run: supabase stop
133+
134+
expo-tests:
135+
name: Expo Tests
136+
runs-on: ubuntu-latest
137+
steps:
138+
- uses: actions/checkout@v4
139+
- uses: actions/setup-node@v4
140+
with:
141+
node-version: 20
142+
- uses: supabase/setup-cli@v1
143+
with:
144+
version: latest
145+
146+
- name: Start Supabase
147+
run: |
148+
supabase start
149+
150+
- name: Build and test expo
151+
run: |
152+
npm clean-install
153+
npm run build
154+
PKG=$(npm pack)
155+
echo "Packed: $PKG"
156+
cd test/integration/expo
157+
npm install "../../../$PKG"
158+
npm install
159+
npm test || npm test
131160
132161
- name: Stop Supabase
133162
run: supabase stop

jest.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,6 @@ const config: Config.InitialOptions = {
1414
'!**/vendor/**',
1515
'!**/vendor/**',
1616
],
17+
testPathIgnorePatterns: ['/node_modules/', '/dist/', '/examples/'],
1718
}
1819
export default config

package-lock.json

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@
2626
"build": "run-s clean format build:*",
2727
"build:main": "tsc -p tsconfig.json",
2828
"build:module": "tsc -p tsconfig.module.json",
29-
"build:umd": "webpack",
29+
"build:umd": "webpack --env mode=production",
3030
"types-generate": "dts-gen -m '@supabase/supabase-js' -s",
3131
"test": "run-s test:types test:run",
3232
"test:all": "run-s test:types test:run test:integration test:integration:browser",
3333
"test:run": "jest --runInBand --detectOpenHandles",
3434
"test:unit": "jest --runInBand --detectOpenHandles test/unit",
35-
"test:coverage": "jest --runInBand --coverage --testPathIgnorePatterns=\"test/integration.*|test/deno.*\"",
35+
"test:coverage": "jest --runInBand --coverage --testPathIgnorePatterns=\"test/integration|test/deno\"",
3636
"test:integration": "jest --runInBand --detectOpenHandles test/integration.test.ts",
3737
"test:integration:browser": "deno test --allow-all test/integration.browser.test.ts",
3838
"test:watch": "jest --watch --verbose false --silent false",

test/integration/expo/.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+
}

test/integration/expo/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: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { cleanup, render, waitFor } 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+
const status = getByTestId('realtime_status').props.children
19+
expect(status).toBe('SUBSCRIBED')
20+
},
21+
{
22+
timeout: 30000, // 30 seconds timeout for waitFor
23+
interval: 1000, // Check every second
24+
onTimeout: (error) => {
25+
const currentStatus = getByTestId('realtime_status').props.children
26+
throw new Error(
27+
`Timeout waiting for SUBSCRIBED status. Current status: ${currentStatus}. ${error.message}`
28+
)
29+
},
30+
}
31+
)
32+
33+
// Unmount the component to trigger cleanup.
34+
unmount()
35+
}, 35000) // 35 seconds timeout for the entire test
36+
})

test/integration/expo/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+
}

test/integration/expo/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+
}

test/integration/expo/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 TEST_ANON_KEY =
7+
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24iLCJleHAiOjE5ODM4MTI5OTZ9.CRXP1A7WOeoJeXxjNni43kdQwgnWNReilDMblYTn_I0'
8+
9+
const supabase = createClient(SUPABASE_URL, TEST_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
Loading
Loading
Loading
Loading
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+
])

test/integration/expo/jest.setup.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
global.WebSocket = require('ws')

0 commit comments

Comments
 (0)