Open giovanniRodighiero opened 2 years ago
IconRegistry
component should be inside ApplicationProvider
import React from 'react';
import { render, fireEvent, act } from '@testing-library/react-native';
import * as eva from '@eva-design/eva';
import { ApplicationProvider, IconRegistry, Button, Text } from '@ui-kitten/components';
import { EvaIconsPack } from '@ui-kitten/eva-icons';
import theme from '../../../uiTheme.json';
describe('<AudioPlayer/> > <MainControlsLeft />', () => {
it('Renders correctly and call the callback fn', async () => {
const spy = jest.fn();
const { getByText, getByA11yLabel } = render(
<ApplicationProvider {...eva} theme={{ ...eva.light, ...theme }}>
<IconRegistry icons={EvaIconsPack} />
<Button
key="back"
accessibilityLabel="backFiveSeconds"
appearance="ghost"
onPress={spy}
>
{(props) => <Text {...props} category="s1" status="basic">-5s</Text>}
</Button>
</ApplicationProvider>
);
expect(getByA11yLabel('backFiveSeconds')).toBeTruthy();
expect(getByText('-5s')).toBeTruthy();
fireEvent(getByA11yLabel('backFiveSeconds'), 'press');
expect(spy).toHaveBeenCalled();
});
});
@giovanniRodighiero
If your problem is solved can you please close the issue? It sparks joy for maintainers āØ
š Bug Report
While testing with
@testing-library/react-native
, if inside the rendered component there is<IconRegistry icons={EvaIconsPack} />
(so every time I need to render a component that has an icon), the functionfireEvent
returnsTypeError: Cannot read property 'pointerEvents' of null
.Without IconRegistry it does work as expected.
To Reproduce
Steps to reproduce the behavior:
Code sample:
Run with
jest <filename>
.Expected behavior
I do expect the press event to be fired correctly.
Link to runnable example or repository (highly encouraged)
UI Kitten and Eva version
Environment information