Skip to content

Commit 3f05280

Browse files
committed
Merge branch 'master' into next
# Conflicts: # .github/workflows/ci.yml
2 parents 5ff313e + b393d68 commit 3f05280

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+24150
-58
lines changed

.github/workflows/ci.yml

Lines changed: 101 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -20,80 +20,143 @@ on:
2020

2121
jobs:
2222
test:
23-
name: Test / OS ${{ matrix.os }} / Node ${{ matrix.node }}
23+
name: Unit + Type Check / Node.js ${{ matrix.node }}
24+
runs-on: ubuntu-latest
2425
strategy:
2526
matrix:
26-
os: [ubuntu-latest]
27-
node: ['20']
28-
29-
runs-on: ${{ matrix.os }}
30-
27+
node: [20]
3128
steps:
3229
- uses: actions/checkout@v4
33-
34-
- name: Set up Node
35-
uses: actions/setup-node@v4
30+
- uses: actions/setup-node@v4
3631
with:
3732
node-version: ${{ matrix.node }}
3833

39-
- name: Run tests
40-
run: |
41-
npm clean-install
42-
npm run test:coverage
34+
- run: npm clean-install
35+
36+
- name: Type Check
37+
run: npm run test:types
38+
39+
- name: Run Unit Tests + Coverage
40+
run: npm run test:coverage
4341

4442
- name: Upload coverage results to Coveralls
4543
uses: coverallsapp/github-action@master
4644
with:
4745
github-token: ${{ secrets.GITHUB_TOKEN }}
4846
path-to-lcov: ./test/coverage/lcov.info
4947

50-
integration:
51-
name: Integration / OS ${{ matrix.os }} / Node ${{ matrix.node }} / Deno ${{ matrix.deno }}
48+
deno-tests:
49+
name: Deno Tests / ${{ matrix.deno }}
50+
runs-on: ubuntu-latest
5251
strategy:
5352
matrix:
54-
os: [ubuntu-latest]
55-
node: ['20']
5653
deno: ['1.x', '2.x']
57-
58-
runs-on: ${{ matrix.os }}
59-
6054
steps:
6155
- uses: actions/checkout@v4
62-
63-
- name: Set up Node
64-
uses: actions/setup-node@v4
65-
with:
66-
node-version: ${{ matrix.node }}
67-
6856
- uses: denoland/setup-deno@v2
6957
with:
7058
deno-version: ${{ matrix.deno }}
71-
72-
- name: Setup Supabase
73-
uses: supabase/setup-cli@v1
59+
- uses: supabase/setup-cli@v1
7460
with:
7561
version: latest
7662

7763
- name: Start Supabase
78-
run: |
79-
supabase start
64+
run: supabase start
8065

81-
- name: Build
66+
- name: Run Deno Tests
8267
run: |
8368
npm clean-install
8469
npm run build
70+
cd test/deno
71+
npm install
72+
npm test || npm test
8573
86-
- name: Run tests
74+
- name: Run integration and browser tests on Deno 2.x only
8775
if: ${{ matrix.deno == '2.x' }}
8876
run: |
77+
npm run test:integration:browser
78+
79+
- name: Stop Supabase
80+
run: supabase stop
81+
82+
node-integration:
83+
name: Node Integration
84+
runs-on: ubuntu-latest
85+
steps:
86+
- uses: actions/checkout@v4
87+
- uses: actions/setup-node@v4
88+
with:
89+
node-version: 20
90+
- uses: supabase/setup-cli@v1
91+
with:
92+
version: latest
93+
94+
- name: Start Supabase
95+
run: supabase start
96+
97+
- name: Run integration tests
98+
run: |
99+
npm clean-install
100+
npm run build
89101
npm run test:integration || npm run test:integration
90-
# npm run test:integration:browser
91102
92-
- name: Run Deno tests
103+
- name: Stop Supabase
104+
run: supabase stop
105+
106+
next-integration:
107+
name: Next.js Integration
108+
runs-on: ubuntu-latest
109+
steps:
110+
- uses: actions/checkout@v4
111+
- uses: actions/setup-node@v4
112+
with:
113+
node-version: 20
114+
- uses: supabase/setup-cli@v1
115+
with:
116+
version: latest
117+
118+
- name: Start Supabase
119+
run: supabase start
120+
121+
- name: Install Playwright browsers and dependencies
122+
run: npx playwright install --with-deps
123+
124+
- name: Run integration tests
93125
run: |
94-
cd test/deno
95-
npm test || npm test
126+
cd test/integration/next
127+
npm install
128+
npx playwright install
129+
npm run test
96130
97131
- 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
98147
run: |
99-
supabase stop
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
160+
161+
- name: Stop Supabase
162+
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: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,17 @@
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",
34-
"test:coverage": "jest --runInBand --coverage --testPathIgnorePatterns=\"test/integration.*|test/deno.*\"",
34+
"test:unit": "jest --runInBand --detectOpenHandles test/unit",
35+
"test:coverage": "jest --runInBand --coverage --testPathIgnorePatterns=\"test/integration|test/deno\"",
3536
"test:integration": "jest --runInBand --detectOpenHandles test/integration.test.ts",
3637
"test:integration:browser": "deno test --allow-all test/integration.browser.test.ts",
37-
"test:db": "cd infra/db && docker-compose down && docker-compose up -d && sleep 5",
3838
"test:watch": "jest --watch --verbose false --silent false",
39-
"test:clean": "cd infra/db && docker-compose down",
40-
"test:types": "run-s build:module && tsd --files test/*.test-d.ts",
39+
"test:types": "run-s build:module && tsd --files test/types/*.test-d.ts",
4140
"docs": "typedoc --entryPoints src/index.ts --out docs/v2 --includes src/**/*.ts",
4241
"docs:json": "typedoc --entryPoints src/index.ts --includes src/**/*.ts --json docs/v2/spec.json --excludeExternals",
4342
"serve:coverage": "npm run test:coverage && serve test/coverage"

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+
}

0 commit comments

Comments
 (0)