ComuniTEA’s test suite uses Jest with theDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/ElthonJohan/comunitea/llms.txt
Use this file to discover all available pages before exploring further.
jest-expo preset and React Native Testing Library to verify that core modules initialize correctly and that the application’s data contracts are sound. The current suite focuses on smoke tests — fast, low-overhead tests that confirm modules load without errors and export the values and shapes expected by the rest of the app. The suite is designed to grow incrementally with the project; new feature tests slot directly into the existing configuration without any setup changes.
Test Framework
| Tool | Version | Role |
|---|---|---|
jest | ^29.7.0 | Test runner |
jest-expo | ~57.0.2 | Expo-aware Jest preset — handles Metro transforms and native mocks |
@testing-library/react-native | ^13.3.3 | Component and hook testing utilities |
react-test-renderer | 19.0.0 | Required peer for React Native Testing Library |
@types/jest | ^29.5.14 | TypeScript types for describe, it, expect, etc. |
package.json under the "jest" key:
Running Tests
Run the full test suite
**/__tests__/**/*.test.{ts,tsx}. Exits with code 0 even if no tests are discovered (see the --passWithNoTests note below).The
test script uses the --passWithNoTests flag: jest --passWithNoTests. This is intentional — the test suite starts minimal and expands alongside the project. CI pipelines will not fail on a fresh branch that hasn’t added tests yet.Module Mocks
React Native’s native modules are not available in the Node.js environment that Jest runs in. ComuniTEA handles this at two levels.Built-in Reanimated Mock
react-native-reanimated ships an official Jest mock. The moduleNameMapper points to it directly:
Worklets Mock
react-native-worklets (a peer dependency of Reanimated 4) has no built-in mock and will crash Jest with a native module error. A manual mock is provided at __mocks__/react-native-worklets.js:
Babel Config — Reanimated Disabled in Tests
babel.config.js disables the Reanimated Babel plugin when NODE_ENV=test, preventing the worklets transform from running during the Jest pass:
Per-Test Native Module Mocks
Tests that import modules with native dependencies declarejest.mock() calls at the top of the file. The smoke test file demonstrates the full set of mocks required to load the Supabase client and audio subsystem:
Path Aliases in Tests
ThemoduleNameMapper in the Jest config maps the @/ prefix for test imports, alongside native module mocks:
require('@/lib/supabase') inside a test file resolves to <rootDir>/lib/supabase. Note that the Jest ^@/(.*)$ mapper uses a different prefix convention from the TypeScript path aliases in tsconfig.json (@lib/*, @features/*, etc.), which are resolved by the Metro bundler and TypeScript compiler but not by Jest. In test files, use the @/ prefix or relative paths (e.g., ../../lib/supabase) to ensure correct resolution. No separate Babel plugin or Jest transform is needed for this mapper.
Transform Ignore Patterns
By default Jest does not transformnode_modules. ComuniTEA’s transformIgnorePatterns opts several packages back into the Babel transform pipeline because they ship ES module or JSX source that Node.js cannot execute natively:
| Package group | Reason |
|---|---|
react-native, jest-react-native | Core RN source ships untransformed JSX |
@react-native(-community)? | Community modules use JSX/ESM |
expo, expo-*, @expo/*, @expo-google-fonts/* | Expo packages use JSX and ESM syntax |
react-navigation, @react-navigation/* | Uses JSX |
lucide-react-native | Ships ESM icons |
react-native-svg, native-base | JSX source |
Smoke Tests
The first test suite lives at__tests__/smoke/core.test.ts — Phase 0 smoke tests that verify the core modules load and export valid data shapes.
Supabase Client Initialization
Verifies that
lib/supabase exports a valid Supabase client with .from() and .auth when EXPO_PUBLIC_SUPABASE_URL and EXPO_PUBLIC_SUPABASE_ANON_KEY are present in the environment.Vocabulary Constants
Confirms that
constants/Vocabulary.ts exports a non-empty VOCABULARY object where each entry contains at least one item with string id and label fields.Category Constants
Confirms that
constants/Categories.ts exports a non-empty BASIC_CATEGORIES array where each element has string id and label fields.Missing Env Var Guard
Verifies that
lib/supabase throws an error prefixed with [ComuniTEA] when the Supabase environment variables are absent, catching misconfigured deployments at startup.require() calls:
TypeScript in Tests
All test files use.ts / .tsx extensions and are fully type-checked by @types/jest. The jest-expo preset wires up the necessary TypeScript transform through Babel.
The tsconfig.json include glob (**/*.ts, **/*.tsx) covers the __tests__/ directory automatically — no extra tsconfig entry is needed for test files.
Testing Guidelines for Contributors
Where to Place Test Files
All tests live under__tests__/ and must match the pattern **/*.test.{ts,tsx}:
Mocking Supabase Calls
For feature tests that involve Supabase queries, mock the client at the module level so tests are fast and deterministic:Testing Hooks with React Native Testing Library
UserenderHook from @testing-library/react-native to test custom hooks in isolation: