Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: migrate example tests to @testing-library/react-native #101

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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
9 changes: 4 additions & 5 deletions template/__tests__/App.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
*/

import React from 'react';
import ReactTestRenderer from 'react-test-renderer';
import { render, screen } from '@testing-library/react-native';
import App from '../App';

test('renders correctly', async () => {
await ReactTestRenderer.act(() => {
ReactTestRenderer.create(<App />);
});
test('renders correctly', () => {
render(<App />);
expect(screen.getByText('Welcome to React Native')).toBeOnTheScreen();
});
1 change: 1 addition & 0 deletions template/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"@react-native/eslint-config": "0.78.0-main",
"@react-native/metro-config": "0.78.0-main",
"@react-native/typescript-config": "0.78.0-main",
"@testing-library/react-native": "^13.0.1",
"@types/jest": "^29.5.13",
"@types/react": "^19.0.0",
"@types/react-test-renderer": "^19.0.0",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you remove this and line 34 also?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deps on react-test-renderer and @types/ have to stay, as RNTL still uses RTR under the hood. RNTL cannot declare a regular dep on RTR, as user's react and RTR versions have to match. The next major RNTL version will work without RTR.

Expand Down