How to use the react-testing-library.render function in react-testing-library

To help you get started, we’ve selected a few react-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 MatejBransky / react-katex / index.spec.js View on Github external
test('invalid type of expression in props.math', () => {
      let $;
      /* eslint-disable-next-line */
      console.error = jest.fn();
      $ = render();
      expect(
        $.queryByText(/KaTeX can only parse string typed expression/)
      ).not.toBeNull();
    });
github Jibbedi / react-wizard-primitive / tests / index.spec.tsx View on Github external
test("it should work with jsx instead of function as child", () => {
  const container = render();
  checkForwardsHandling(container);
});
github adhrinae / ts-react-parcel / src / components / __tests__ / App.spec.tsx View on Github external
test('App Component renders with toggle switch', () => {
  const wrap = render()

  expect(wrap.getByTestId('toggle-input')).toBeInTheDocument()
})
github plougsgaard / react-timeout / __tests__ / timing.js View on Github external
test('can cancel 100 callbacks by unmounting why not', (done) => {
    __experimentSetTimeout = 'unchanged'
    let t = testUtils.render()
    let button = t.getByText('RunExperiment')
    let i = 0
    for (i = 0; i < 100; i++) {
      testUtils.fireEvent.click(button)
    }
    setTimeout(() => {
      t.unmount()
    }, 100)
    setTimeout(() => {
      expect(__experimentSetTimeout).toBe('unchanged')
      done()
    }, 500)
  })
})
github testing-library / react-testing-library / examples / __tests__ / react-context.js View on Github external
test('NameProvider composes full name from first, last', () => {
  const tree = (
    
      
        {value =&gt; <span>Received: {value}</span>}
      
    
  )
  const {getByText} = render(tree)
  expect(getByText(/^Received:/).textContent).toBe('Received: Boba Fett')
})
github derrickbeining / react-atom / test / initialize.spec.tsx View on Github external
    expect(() =&gt; void render()).toThrow(Error);
    console.error = e;
github iusehooks / redhooks / __tests__ / connect.spec.js View on Github external
button = wrapper.container.firstChild;
    expect(button.textContent).toBe("0");
    fireEvent.click(button);
    expect(button.textContent).toBe("1");

    mapDispatchToProps = {
      dispatch: action =&gt; action,
      nested: { add: type =&gt; dispatch({ type }) },
      ingored: "hi"
    };

    ConnectedCMP = connectCompNoMapDispatch(
      mapStateToProps,
      mapDispatchToProps
    );
    wrapper = render(
      
        
      
    );
    button = wrapper.container.firstChild;
    expect(button.textContent).toBe("0");
    fireEvent.click(button);
    expect(button.textContent).toBe("1");

    mapDispatchToProps = dispatch =&gt; ({});

    ConnectedCMP = connectCompNoMapDispatch(
      mapStateToProps,
      mapDispatchToProps
    );
    wrapper = render(
github topheman / react-fiber-experiments / src / testUtils.js View on Github external
const renderWithRouter = (ui, renderOptions = {}, { pathname = "/" } = {}) =&gt; {
  const history = createHistory(createMemorySource(pathname));
  return render(
    {ui},
    renderOptions
  );
};
github MatejBransky / react-katex / index.spec.js View on Github external
test('expression via props.math', () =&gt; {
    expect(render().container).toMatchSnapshot();
  });
github GSS-FED / vital-ui-kit-react / packages / form / src / checkbox / Checkbox.spec.tsx View on Github external
it('should render with Custom Theme', () =&gt; {
    const checkbox = render(
       ({
          checkbox: {
            label: {
              color: 'red',
            },
          },
        })}
      &gt;
        
      ,
    );
    expect(checkbox).toMatchSnapshot();
  });