react-native-testsmith
v0.1.2
Published
Local-first React Native testing CLI for Jest and Testing Library
Maintainers
Readme
react-native-testsmith
Production-ready CLI for React Native unit testing with Jest and React Native Testing Library.
1.0.1 Update
- Switched to API-first AI generation (Ollama removed on this branch)
initnow runs Jest setup automaticallygeneratenow runs full pipeline: scan + API check + per-file AI generation- Long files are chunked automatically for free-tier model limits
- Added per-file progress logs and final generation summary counts
Why this exists
- Automates painful Jest + RN config
- Scans your components/screens and builds metadata
- Generates stable test templates quickly
- Supports API-driven AI test generation with chunking for large files
Install
npm i -g react-native-testsmithOr inside a project:
npm i -D react-native-testsmithFor local development from this repo:
npm i
npm run build
npm i -g .
react-native-testsmith --helpIf you see command not found, install globally (npm i -g .) or run with npx.
Commands
react-native-testsmith init
react-native-testsmith generate
react-native-testsmith generate --failed-only
react-native-testsmith doctor
react-native-testsmith doctor --jsonTypical workflow
react-native-testsmith init
react-native-testsmith generateFull setup steps (end-to-end)
- Install CLI
npm i -g react-native-testsmith- Move to your React Native app
cd mobileApp- Create config
react-native-testsmith init- Configure Jest and required mocks
# already done by init
# optional manual run:
react-native-testsmith setup- Run complete generation pipeline (scan + API check + per-file AI generation)
react-native-testsmith generate- Verify setup health
react-native-testsmith doctor
react-native-testsmith doctor --jsonSetup output
setup creates:
jest.config.jsjest.setup.ts__mocks__/fileMock.tsx__mocks__/styleMock.ts- RN mock shims for common libraries
- installs
@testing-library/react-nativeif missing
When you pass --with-native-mocks, setup also creates:
__mocks__/react-native-config.ts__mocks__/react-native-device-info.ts__mocks__/react-native-vector-icons-MaterialIcons.ts
Use --dry-run to preview all setup changes safely before writing files.
init runs setup automatically. You can still run setup directly when needed.
Test output structure
generate mirrors your source structure in __tests__ when testFileStyle is tests-dir.
Example:
src/components/Button.tsx->__tests__/components/Button.test.tsxsrc/screens/auth/Login.js->__tests__/screens/auth/Login.test.js
API notes
generateis the primary AI command now (project-wide).RN_TESTSMITH_API_URLoverrides endpoint andRN_TESTSMITH_API_KEYis optional.- Long files are chunked automatically and then synthesized.
scanincludesApp.ts,App.js,App.tsx, andApp.jsxat project root.- Terminal output includes per-file progress and final AI response/generated counts.
- 5xx API errors/timeouts are retried automatically (configurable via env vars).
- Failed files are stored in
.react-native-testsmith/failed-files.jsonand can be retried withgenerate --failed-only.
CI
GitHub Actions CI is included at .github/workflows/ci.yml:
- typecheck
- build
- test
Notes
- Generated tests are templates and should be refined by developers.
- Use
--forceif you want to overwrite existing generated files.
Sponsor request
react-native-testsmith is currently free to use.
If this project saves your team time, please sponsor development so we can:
- maintain and improve templates faster
- add broader framework support
- provide optional hosted model inference in the future
- keep docs, CI, and releases production-grade
Interested in sponsoring? Open an issue with title Sponsorship and we will coordinate.
