Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/wojtekmaj/vitest-react-native. Run React Native unit and component tests with Vitest
Something went wrong. Try again.
1.3 kB · 42 lines
TSX
at main
12345678910111213141516171819202122232425262728293031323334353637383940414243import { describe, expect, it, vi } from 'vitest';import { Platform } from 'react-native';import { render, screen } from '@testing-library/react-native';
import { getNativeEntries, NativeDependencies } from './resolution.js';
vi.mock(import('./resolution.js'), async (importOriginal) => { const actual = await importOriginal();
return { ...actual, getNativeEntries: vi.fn(actual.getNativeEntries), };});
describe('getNativeEntries()', () => { it('should use the native package entry for both imports and CommonJS dependencies', () => { const entries = getNativeEntries();
expect(entries).toEqual({ commonJs: 'native', esm: 'native', }); expect(getNativeEntries).toHaveBeenCalledOnce(); });});
describe('<NativeDependencies /> component', () => { it('should resolve platform files from an installed native dependency', async () => { await render(<NativeDependencies />);
const expected = Platform.OS === 'ios' ? 'iOS' : 'Android';
expect(screen.getByText(expected)).toBeOnTheScreen(); });
it('should compile an explicitly configured JSX dependency', async () => { await render(<NativeDependencies />);
expect(screen.getByText('Uncompiled JSX')).toBeOnTheScreen(); });});