diff --git a/examples/react-native/__mocks__/expo-crypto.js b/examples/react-native/__mocks__/expo-crypto.js new file mode 100644 index 00000000000..8b1f0f1a527 --- /dev/null +++ b/examples/react-native/__mocks__/expo-crypto.js @@ -0,0 +1,11 @@ +// Mock for expo-crypto to avoid expo-modules-core native module initialization in Jest +const crypto = require('crypto'); + +module.exports = { + digest: async (algorithm, data) => { + const alg = algorithm.replace('-', '').toLowerCase(); + return crypto.createHash(alg).update(Buffer.from(data)).digest(); + }, + getRandomValues: (array) => crypto.getRandomValues(array), + randomUUID: () => crypto.randomUUID(), +}; diff --git a/examples/react-native/__mocks__/expo-sqlite.js b/examples/react-native/__mocks__/expo-sqlite.js new file mode 100644 index 00000000000..2844946e990 --- /dev/null +++ b/examples/react-native/__mocks__/expo-sqlite.js @@ -0,0 +1,6 @@ +// Mock for expo-sqlite to avoid expo-modules-core native module initialization in Jest +// Tests use STORAGE_MEMORY so no actual SQLite is needed +module.exports = { + openDatabaseAsync: jest.fn(), + openDatabaseSync: jest.fn(), +}; diff --git a/examples/react-native/jest.config.js b/examples/react-native/jest.config.js index 6b759c8090f..0ad7a9c5c59 100644 --- a/examples/react-native/jest.config.js +++ b/examples/react-native/jest.config.js @@ -3,17 +3,12 @@ const transformIgnorePatterns = [ ]; module.exports = { - projects: [ - { - preset: "jest-expo/ios", - transformIgnorePatterns, - }, - { - preset: "jest-expo/android", - transformIgnorePatterns, - }, - ], - + preset: "@react-native/jest-preset", + transformIgnorePatterns, testRegex: "(/__tests__/.*|\\.(test|spec))\\.(ts|tsx|js)$", + moduleNameMapper: { + '^expo-crypto$': '/__mocks__/expo-crypto.js', + '^expo-sqlite$': '/__mocks__/expo-sqlite.js', + }, }; \ No newline at end of file diff --git a/examples/react-native/package.json b/examples/react-native/package.json index 2e20b8c381f..ce3b0a659c8 100644 --- a/examples/react-native/package.json +++ b/examples/react-native/package.json @@ -15,6 +15,7 @@ "devDependencies": { "@babel/core": "7.29.0", "@expo/cli": "56.1.11", + "@react-native/jest-preset": "0.85.3", "babel-preset-expo": "54.0.9", "buffer": "6.0.3", "cross-fetch": "4.1.0", @@ -25,7 +26,7 @@ "jest-expo": "54.0.16", "random-token": "0.0.8", "react": "19.2.6", - "react-native": "0.84.1", + "react-native": "0.85.3", "react-native-gesture-handler": "2.31.2", "react-native-get-random-values": "2.0.0", "react-native-quick-base64": "3.0.0",