FIXING BUN JEST (#719)

* FIXING BUN JEST

* Update Jest configuration and add nitro-fetch mocks for improved testing
This commit is contained in:
skalthoff
2025-11-24 17:17:15 -08:00
committed by GitHub
parent 58597b07d8
commit a8564b4a90
5 changed files with 41 additions and 2 deletions

View File

@@ -21,6 +21,17 @@ jobs:
with:
bun-version: 1.3.2
- name: 📦 Cache dependencies
uses: actions/cache@v4
with:
path: |
~/.bun/install/cache
node_modules
.jest-cache
key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lockb') }}
restore-keys: |
${{ runner.os }}-bun-
- name: 💬 Echo package.json version to Github ENV
run: echo VERSION_NUMBER=$(bun -p "require('./package.json').version") >> $GITHUB_ENV
@@ -31,7 +42,7 @@ jobs:
run: bun tsc
- name: 🧪 Run yarn test
run: bun test
run: CI=true bun run test
- name: 🦋 Check Styling
run: bun run format:check

1
.gitignore vendored
View File

@@ -66,6 +66,7 @@ node_modules/
# testing
/coverage
.jest-cache
# Yarn
#.yarn/*

View File

@@ -2,6 +2,11 @@
module.exports = {
preset: 'react-native',
testTimeout: 10000,
// Performance optimizations for CI
maxWorkers: process.env.CI ? 2 : '50%',
cacheDirectory: '.jest-cache',
setupFiles: ['./node_modules/react-native-gesture-handler/jestSetup.js'],
setupFilesAfterEnv: [
'./jest/setup/setup.ts',
@@ -13,6 +18,7 @@ module.exports = {
'./jest/setup/rnfs.ts',
'./jest/setup/rntp.ts',
'./jest/setup/sentry.ts',
'./jest/setup/nitro-fetch.ts',
'./jest/setup/nitro-image.ts',
'./jest/setup/nitro-ota.ts',
'./tamagui.config.ts',

21
jest/setup/nitro-fetch.ts Normal file
View File

@@ -0,0 +1,21 @@
// Mock for react-native-nitro-fetch
jest.mock('react-native-nitro-fetch', () => ({
nitroFetchOnWorklet: jest.fn(() => Promise.resolve({})),
nitroFetch: jest.fn(() => Promise.resolve({})),
}))
// Update the nitro-modules mock to include the box method
jest.mock('react-native-nitro-modules', () => {
const actual = jest.requireActual('react-native-nitro-modules')
return {
...actual,
NitroModules: {
...actual?.NitroModules,
createModule: jest.fn(),
install: jest.fn(),
createHybridObject: jest.fn(() => ({})),
box: jest.fn((value) => value), // Mock the box method
},
createNitroModule: jest.fn(),
}
})

View File

@@ -11,7 +11,7 @@
"ios": "react-native run-ios",
"lint": "eslint .",
"start": "react-native start",
"test": "jest",
"test": "bunx jest",
"tsc": "tsc",
"codegen": "env DEBUG=metro:* react-native codegen",
"clean:ios": "cd ios && pod deintegrate",