Skip to main content
Mock services activate automatically when API keys are missing. Add credentials via yarn setup to use real services - no code changes needed.

How It Works

// Backend mock activates based on provider and credentials
export const USE_MOCK_SUPABASE = __DEV__ && isSupabase && !process.env.EXPO_PUBLIC_SUPABASE_URL
export const USE_MOCK_CONVEX = __DEV__ && isConvex && !process.env.EXPO_PUBLIC_CONVEX_URL

Available Mocks

ServiceMock Behavior
SupabaseAuth, database, storage, realtime - all in-memory
ConvexAuth, queries, mutations - all in-memory
PostHogEvents logged to console, feature flags return false
SentryErrors logged to console
RevenueCatPurchases always succeed, dev menu toggle for pro status

Backend Mocks

Full simulation of auth, database, storage, and realtime.
import { supabase } from '@/services/supabase'

// Same code works with mock or real Supabase
await supabase.auth.signInWithPassword({
  email: 'test@example.com',
  password: 'password'
})

const { data } = await supabase
  .from('posts')
  .select('*')
  .eq('author_id', 'user-123')

await supabase.storage
  .from('avatars')
  .upload('avatar.jpg', file)

Test Accounts

{ email: 'demo@shipnative.app', password: 'demo123' }
{ email: 'test@shipnative.app', password: 'test123' }

Testing Utilities

import { mockSupabaseHelpers } from '@/services/mocks/supabase'

// Seed test data
mockSupabaseHelpers.seedTable('posts', [
  { id: 1, title: 'Test Post', author_id: 'user-123' },
])

// Clear all mock data
mockSupabaseHelpers.clearAll()

Other Service Mocks

RevenueCat

import { mockRevenueCat } from '@/services/mocks/revenueCat'

// Toggle pro status for testing
mockRevenueCat.setProStatus(true)

// Or use the Dev Menu (Cmd+D / Cmd+M)

PostHog

Events logged to console with [MockPostHog] prefix. Feature flags return false by default.

Sentry

Errors logged to console with [MockSentry] prefix instead of being sent to Sentry.

Console Logging

All mock operations log to console:
[MockSupabase] Sign in: user@example.com
[MockConvex] Query: api.posts.list
[MockPostHog] Event: button_clicked
[MockRevenueCat] Purchase: pro_monthly

Limitations

  • Data clears on app restart
  • Security policies (RLS, function auth) not enforced
  • Network performance not simulated
  • Realtime subscriptions simulated locally
For production testing, connect real services via yarn setup.

Switching to Real Services

yarn setup
The wizard prompts for credentials. Once configured, the app automatically uses real services - no code changes needed. You can also manually set environment variables in apps/app/.env:
EXPO_PUBLIC_BACKEND_PROVIDER=supabase
EXPO_PUBLIC_SUPABASE_URL=https://your-project.supabase.co
EXPO_PUBLIC_SUPABASE_PUBLISHABLE_KEY=your-key
Restart Metro after changing environment variables: yarn start --clear