Files
react-native/template/__tests__/App.test.tsx
T
Xun Sun 9af3c9654a switch from @types/jest to @jest/globals (#36068)
Summary:
Originally proposed in https://github.com/react-native-community/discussions-and-proposals/discussions/592

Main changes are:
- Explicitly importing the global APIs in `App.test.tsx`
- Drop `types/jest` from the devDependency list

Benefits of these changes will be:
- Keep in line with Jest's recommended practice
- Remove a dev-dependency to make dependencies slimmer

References:
- https://github.com/facebook/jest/pull/13133
- https://github.com/DefinitelyTyped/DefinitelyTyped/pull/62037

## Changelog

[GENERAL] [CHANGED] - Switch from `types/jest` to `jest/globals` for new react-native projects

Pull Request resolved: https://github.com/facebook/react-native/pull/36068

Test Plan:
1. Create a new RN project from the modified template
2. Ensure yarn test passes
3. Ensure IDEs do not complain about `App.test.tsx`

Reviewed By: cipolleschi

Differential Revision: D43080151

Pulled By: cortinico

fbshipit-source-id: c9161cb930c78f3a1eaa08ccb6483aa38d52fa3c
2023-02-07 06:16:07 -08:00

18 lines
363 B
TypeScript

/**
* @format
*/
import 'react-native';
import React from 'react';
import App from '../App';
// Note: import explicitly to use the types shiped with jest.
import {it} from '@jest/globals';
// Note: test renderer must be required after react-native.
import renderer from 'react-test-renderer';
it('renders correctly', () => {
renderer.create(<App />);
});