Skip to content

Commit 1b5c308

Browse files
author
georgiy.rusanov
committed
real ws
1 parent a44c7d9 commit 1b5c308

File tree

2 files changed

+4
-47
lines changed

2 files changed

+4
-47
lines changed

examples/expo-app/jest.setup.js

Lines changed: 1 addition & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1 @@
1-
// Jest setup file for Expo app
2-
// This file configures the test environment to use real WebSocket instead of mocks
3-
4-
// Mock expo-router
5-
jest.mock('expo-router', () => ({
6-
useRouter: () => ({
7-
push: jest.fn(),
8-
replace: jest.fn(),
9-
back: jest.fn(),
10-
}),
11-
useLocalSearchParams: () => ({}),
12-
useGlobalSearchParams: () => ({}),
13-
}))
14-
15-
// Mock expo-constants
16-
jest.mock('expo-constants', () => ({
17-
expoConfig: {
18-
extra: {
19-
supabaseUrl: process.env.SUPABASE_URL || 'http://127.0.0.1:54321',
20-
supabaseAnonKey:
21-
process.env.SUPABASE_ANON_KEY ||
22-
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24iLCJleHAiOjE5ODM4MTI5OTZ9.CRXP1A7WOeoJeXxjNni43kdQwgnWNReilDMblYTn_I0',
23-
},
24-
},
25-
}))
26-
27-
// Configure React Native to use real WebSocket
28-
const ReactNative = require('react-native')
29-
if (ReactNative.WebSocket && ReactNative.WebSocket.name === 'WSWebSocketDummy') {
30-
// Replace the dummy WebSocket with real one
31-
ReactNative.WebSocket = require('ws')
32-
}
33-
34-
// Global test setup
35-
global.console = {
36-
...console,
37-
// Uncomment to ignore a specific log level
38-
// log: jest.fn(),
39-
// debug: jest.fn(),
40-
// info: jest.fn(),
41-
// warn: jest.fn(),
42-
// error: jest.fn(),
43-
}
1+
global.WebSocket = require('ws')

examples/expo-app/package.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,8 @@
5555
"private": true,
5656
"jest": {
5757
"preset": "jest-expo",
58-
"setupFilesAfterEnv": [
59-
"<rootDir>/jest.setup.js"
60-
],
61-
"testEnvironment": "node"
58+
"setupFiles": [
59+
"./jest.setup.js"
60+
]
6261
}
6362
}

0 commit comments

Comments
 (0)