Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions .github/workflows/test-harness-android.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Test Harness Android

on:
pull_request:
paths:
- ".github/workflows/test-harness-android.yml"
- "example/android/**"
- "example/src/tests/**"
- "example/__tests__/**"
- "example/rn-harness.config.mjs"
- "example/jest.config.js"
- "package/cpp/**"
- "package/android/**"
- "**/bun.lock"
- "**/react-native.config.js"
- "**/nitro.json"

env:
TARGET_ANDROID_ARCH: x86_64

jobs:
test:
name: Harness Tests (Android)
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v6
- uses: oven-sh/setup-bun@v2

- name: Setup JDK 17
uses: actions/setup-java@v5
with:
distribution: "zulu"
java-version: 17

- name: Enable KVM group perms
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm

- name: Install dependencies (bun)
run: bun install

- name: Run react-native-harness on Android
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 35
arch: x86_64
avd-name: Pixel_8_API_35
working-directory: example/android
script: >-
./gradlew :app:installDebug --no-daemon
-PreactNativeArchitectures=${{ env.TARGET_ANDROID_ARCH }}
&& bun --cwd .. run test:harness:android

66 changes: 66 additions & 0 deletions .github/workflows/test-harness-ios.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Test Harness iOS

on:
pull_request:
paths:
- ".github/workflows/test-harness-ios.yml"
- "example/ios/**"
- "example/src/tests/**"
- "example/__tests__/**"
- "example/rn-harness.config.mjs"
- "example/jest.config.js"
- "package/cpp/**"
- "package/ios/**"
- "**/Podfile.lock"
- "**/*.podspec"
- "**/react-native.config.js"
- "**/nitro.json"
- "**/bun.lock"

jobs:
test:
name: Harness Tests (iOS)
runs-on: macOS-26

steps:
- uses: actions/checkout@v6
- uses: oven-sh/setup-bun@v2

- name: Setup Ruby (bundle)
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.3.0
bundler-cache: true
working-directory: example

- name: Select Xcode 26.2
run: sudo xcode-select -s "/Applications/Xcode_26.2.app/Contents/Developer"

- name: Install Pods
working-directory: example
run: bun pods

- name: Boot iOS Simulator
run: |
xcrun simctl boot "iPhone 17 Pro (26.2)" || true
xcrun simctl bootstatus booted -b

- name: Build and install debug app
working-directory: example/ios
run: |
set -o pipefail
xcodebuild \
CC=clang CPLUSPLUS=clang++ LD=clang LDPLUSPLUS=clang++ \
-derivedDataPath build -UseModernBuildSystem=YES \
-workspace NitroSQLiteExample.xcworkspace \
-scheme NitroSQLiteExample \
-sdk iphonesimulator \
-configuration Debug \
-destination 'platform=iOS Simulator,name=iPhone 17 Pro,OS=26.2' \
ONLY_ACTIVE_ARCH=YES \
install \
CODE_SIGNING_ALLOWED=NO

- name: Run react-native-harness on iOS
run: bun --cwd example run test:harness:ios

3 changes: 3 additions & 0 deletions example/__tests__/typeorm.harness.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { registerTypeORMUnitTests } from '../src/tests/unit'

registerTypeORMUnitTests()
3 changes: 3 additions & 0 deletions example/__tests__/unit.harness.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { registerUnitTests } from '../src/tests/unit'

registerUnitTests()
12 changes: 12 additions & 0 deletions example/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module.exports = {
projects: [
{
displayName: "react-native-harness",
preset: "react-native-harness",
testMatch: [
"**/__tests__/**/*.(test|spec|harness).(js|jsx|ts|tsx)",
],
},
],
};

10 changes: 9 additions & 1 deletion example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@
"pods": "cd ios && bundle exec pod install",
"typecheck": "tsc --noEmit",
"lint": "eslint \"**/*.{js,ts,tsx}\" --fix",
"codegen": "bun react-native codegen"
"codegen": "bun react-native codegen",
"test:harness": "react-native-harness",
"test:harness:android": "react-native-harness --harnessRunner android",
"test:harness:ios": "react-native-harness --harnessRunner ios"
},
"dependencies": {
"@craftzdog/react-native-buffer": "^6.0.5",
Expand Down Expand Up @@ -49,6 +52,11 @@
"@types/node": "^22.7.4",
"@types/react": "^19.1.1",
"@types/react-test-renderer": "^19.1.0",
"@react-native-harness/cli": "1.0.0-alpha.21",
"@react-native-harness/jest": "1.0.0-alpha.21",
"@react-native-harness/platform-android": "1.0.0-alpha.21",
"@react-native-harness/platform-apple": "1.0.0-alpha.21",
"react-native-harness": "1.0.0-alpha.21",
"mocha": "^10.1.0",
"postinstall-postinstall": "^2.1.0",
"react-test-renderer": "19.1.1"
Expand Down
35 changes: 35 additions & 0 deletions example/rn-harness.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import {
androidPlatform,
androidEmulator,
} from "@react-native-harness/platform-android";
import {
applePlatform,
appleSimulator,
} from "@react-native-harness/platform-apple";

const config = {
entryPoint: "./index.js",
appRegistryComponentName: "NitroSQLiteExample",

runners: [
androidPlatform({
name: "android",
device: androidEmulator("Pixel_8_API_35"),
bundleId: "com.margelo.rnnitrosqlite.example",
}),
applePlatform({
name: "ios",
device: appleSimulator("iPhone 17 Pro", "26.2"),
bundleId: "com.margelo.rnnitrosqlite.example",
}),
],

defaultRunner: "android",
bridgeTimeout: 120000,

resetEnvironmentBetweenTestFiles: true,
unstable__skipAlreadyIncludedModules: false,
};

export default config;

4 changes: 2 additions & 2 deletions example/src/tests/unit/common.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Chance } from 'chance'
import { NitroSQLiteError } from 'react-native-nitro-sqlite'
import { resetTestDb } from '../db'
import chai from 'chai'
import { expect as harnessExpect } from 'react-native-harness'

export const TEST_ERROR_CODES = {
EXPECT_NITRO_SQLITE_ERROR: 'Should have thrown a valid NitroSQLiteError',
Expand All @@ -15,7 +15,7 @@ export function isNitroSQLiteError(e: unknown): e is NitroSQLiteError {
return e instanceof NitroSQLiteError
}

export const expect = chai.expect
export const expect = harnessExpect
export const chance = new Chance()

export function setupTestDb() {
Expand Down
2 changes: 1 addition & 1 deletion example/src/tests/unit/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { beforeEach, describe } from '../MochaRNAdapter'
import { beforeEach, describe } from 'react-native-harness'
import { setupTestDb } from './common'
import registerExecuteUnitTests from './specs/operations/execute.spec'
import registerTransactionUnitTests from './specs/operations/transaction.spec'
Expand Down
Loading
Loading