Create FasterCreate Faster
Testing

Jest

Unit and component testing for Expo apps with the jest-expo preset and React Native Testing Library.

Supported frameworks

→ jest-expo Documentation

What create-faster adds

The jest-expo preset wired up with React Native Testing Library.

Files added:

jest.config.js              # jest-expo preset
tests/
└── unit/
    └── example.test.tsx    # Sample component test

jest.config.js

jest.config.js
module.exports = {
  preset: 'jest-expo',
};

Testing Library

Since Testing Library 14, render is asynchronous, so tests await it:

tests/unit/example.test.tsx
await render(<Text>Hello</Text>);
expect(screen.getByText('Hello')).toBeTruthy();

Scripts:

  • test - Run the suite (jest)
  • test:watch - Watch mode (jest --watch)

The Expo tsconfig.json adds jest to compilerOptions.types (TypeScript 6 no longer loads every @types package on its own) and includes **/*.tsx, so test files under tests/ are type-checked without changes.

On this page