How to use react-native-testing-library - 10 common examples

To help you get started, we’ve selected a few react-native-testing-library examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github akveo / react-native-ui-kitten / src / components / theme / application / application.spec.tsx View on Github external
it('* theme switching checks', () => {
    const application: RenderAPI = render();
    fireEvent(application.getByType(Button), 'press');
    const { output } = shallow(application.getByType(ApplicationProvider));

    const stringify = (obj: any): string => {
      return JSON.stringify(obj);
    };

    // @ts-ignore just for theme prop changing
    expect(stringify(output.props.theme)).toBe(JSON.stringify(themeInverse));
  });
github paularmstrong / build-tracker / src / app / src / components / __tests__ / DrawerLink.tsx View on Github external
test('changes font color', () => {
      const { getByType } = render();
      const root = getByType(Text);
      expect(StyleSheet.flatten(root.props.style)).not.toMatchObject({
        color: expect.any(String)
      });
      fireEvent(root, 'mouseEnter');
      expect(StyleSheet.flatten(root.props.style)).toMatchObject({
        color: Theme.Color.Primary40
      });
    });
  });
github paularmstrong / build-tracker / src / app / src / components / __tests__ / DrawerLink.tsx View on Github external
test('adds a bg color', () => {
      const { getByProps } = render();
      const root = getByProps({ accessibilityRole: 'link' });
      expect(StyleSheet.flatten(root.props.style)).not.toMatchObject({
        backgroundColor: expect.any(String)
      });
      fireEvent(root, 'mouseEnter');
      expect(StyleSheet.flatten(root.props.style)).toMatchObject({
        backgroundColor: Theme.Color.Primary00
      });
    });
github learn-tdd-in / react-native / src / __tests__ / NewMessageForm.spec.js View on Github external
beforeEach(() => {
      sendHandler = jest.fn();

      ({getByTestId} = render());

      fireEvent.changeText(getByTestId('messageText'), messageText);
      fireEvent.press(getByTestId('sendButton'));
    });
github chagasaway / tdc-2019 / integration-tests / page-objects / AmountInputPageObject.ts View on Github external
public fillAmount(amount: string) {
    const input = this.getInput();
    fireEvent.changeText(input, amount);
  }
github learn-tdd-in / react-native / test / components / NewMessageForm.spec.js View on Github external
beforeEach(() => {
      sendHandler = jest.fn();
      ({ getByTestId } = render());

      fireEvent.changeText(getByTestId('messageText'), messageText);
      fireEvent.press(getByTestId('sendButton'));
    });
github akveo / react-native-ui-kitten / src / framework / ui / tabNavigator / bottomTabNavigator.spec.tsx View on Github external
it('* tab choose', () => {
    const onSelect = jest.fn();
    const component = render(
      
         <img style="{style}/">}
          title='Screen 1'
          selected={false}/&gt;
         <img style="{style}/">}
          title='Screen 2'
          selected={true}/&gt;
         <img style="{style}/">}
          title='Screen 3'
          selected={false}/&gt;
github akveo / react-native-ui-kitten / src / components / ui / icon / icon.spec.tsx View on Github external
it('* should pass props to an icon component', () =&gt; {
    const component = render(
      ,
    );

    expect(component.getByTestId('custom-test-id')).toBeTruthy();
  });
github akveo / react-native-ui-kitten / src / components / ui / calendar / calendar.spec.tsx View on Github external
it('* date changes', () =&gt; {
    const expectedDate: Date = new Date(2019, CURRENT_MONTH, 5);
    const application: RenderAPI = render();

    fireEvent.press(application.getAllByText('5')[0]);
    const { date } = application.getByType(Calendar).props;

    expect(date.toString()).toBe(expectedDate.toString());
  });
github akveo / react-native-ui-kitten / src / framework / ui / sample / sample.component.spec.tsx View on Github external
it('Checks Sample component passes correct text props', async () =&gt; {
  const text = 'Hello, World!';
  const component = render(
    ,
  );
  const textComponent = component.getByName('Text');
  expect(textComponent.props.children).toEqual(text);
});

react-native-testing-library

Simple React Native testing utilities helping you write better tests with less effort

MIT
Latest version published 4 years ago

Package Health Score

67 / 100
Full package analysis