Skip to main content
Off Grid has comprehensive test coverage across React Native, Android, iOS, and end-to-end flows. All tests run automatically on every pull request via GitHub Actions.

Test Frameworks

Tests run across three platforms with specialized frameworks:

Running Tests

All Tests

Run the complete test suite (Jest + Android + iOS):
This command runs:
  1. Jest tests with coverage
  2. Android JUnit tests
  3. iOS XCTest suite

React Native Tests (Jest)

Android Tests (JUnit)

Android tests require the Gradle wrapper in android/. Ensure you’ve run cd android && ./gradlew clean at least once.

iOS Tests (XCTest)

iOS tests require Xcode 15+ and a configured iOS Simulator. The default simulator is iPhone 16 - adjust the -destination flag if using a different simulator.

End-to-End Tests (Maestro)

Maestro tests verify critical user flows end-to-end.
1

Install Maestro

2

Start the app

Launch the app on an emulator/simulator:
3

Run E2E tests

E2E tests require a running app on an emulator/simulator. They test:
  • App launch and onboarding
  • Chat message flow
  • Model download and switching
  • Image generation
  • Settings changes

Test Coverage

Off Grid uses Codecov for test coverage tracking: codecov

Viewing Coverage Reports

After running Jest with --coverage, view the HTML report:

Coverage Requirements

  • Jest coverage is uploaded to Codecov on every PR
  • Codecov checks enforce coverage thresholds (no decrease in coverage allowed)
  • Uncovered lines are flagged in PR comments
Add tests for new code before submitting PRs. The CI pipeline will reject PRs that decrease test coverage.

Continuous Integration (GitHub Actions)

All tests run automatically on every PR and push to main via GitHub Actions.

CI Workflow Jobs

The CI workflow (.github/workflows/ci.yml) includes:
Job: lintRuns on: macos-latestSteps:
  1. ESLint (JavaScript/TypeScript)
  2. SwiftLint (iOS Swift code)
  3. Android Lint (Kotlin code)
This runs:
  • eslint .
  • swiftlint lint --quiet
  • cd android && ./gradlew :app:lintDebug

CI Badge

CI The CI badge shows the current status of the main branch.

Pre-Commit Quality Gates (Husky)

Off Grid uses Husky to run quality gates automatically on every git commit. Tests are scoped to the file types you staged.

Pre-Commit Hook Behavior

Requirements

  • SwiftLint: brew install swiftlint (skipped with a warning if not installed)
  • Android: Gradle wrapper in android/
If the hook fails, fix the issue and recommit. Never skip with --no-verify - this bypasses critical quality checks.

Pre-Commit Hook Source

The hook is defined in .husky/pre-commit:
.husky/pre-commit

Writing Tests

Jest Tests (React Native)

Example test for a Zustand store:
src/stores/__tests__/chatStore.test.ts

Android Tests (JUnit)

Example test for a Kotlin module:
android/app/src/test/java/ai/offgridmobile/PdfExtractorTest.kt

iOS Tests (XCTest)

Example test for a Swift module:
ios/OffgridMobileTests/PDFExtractorTests.swift

Troubleshooting

Use --forceExit to force Jest to exit after tests complete:
This is already included in the npm test script.
Ensure you’ve initialized the Android project:
Check available simulators:
Update the -destination flag in the test command to match an available simulator.
Install SwiftLint via Homebrew:
Codecov will block the PR if coverage decreases. Add tests for new code:
  1. Check the Codecov report in the PR comment
  2. Identify uncovered lines
  3. Write tests to cover those lines
  4. Push updated code

Next Steps

Contributing Guide

Learn the full contribution workflow including PR reviews

Project Structure

Understand the codebase organization