mirror of
https://github.com/Jellify-Music/App.git
synced 2026-02-07 02:58:48 -06:00
FIXING BUN JEST (#719)
* FIXING BUN JEST * Update Jest configuration and add nitro-fetch mocks for improved testing
This commit is contained in:
13
.github/workflows/run-jest-test-suite.yml
vendored
13
.github/workflows/run-jest-test-suite.yml
vendored
@@ -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
1
.gitignore
vendored
@@ -66,6 +66,7 @@ node_modules/
|
||||
|
||||
# testing
|
||||
/coverage
|
||||
.jest-cache
|
||||
|
||||
# Yarn
|
||||
#.yarn/*
|
||||
|
||||
@@ -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
21
jest/setup/nitro-fetch.ts
Normal 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(),
|
||||
}
|
||||
})
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user