Skip to content

Is there a reason @testing-library/dom isn't installed by default? #11426

Answered by mgpwilson
mgpwilson asked this question in Q&A
Discussion options

You must be logged in to vote

Nevermind, solved my problem. If I destructure the return value from the render function of @testing-library/react for my getbyRole function, rather than from screen, like below:

import { render } from '@testing-library/react';
import userEvent from '@testing-library/user-event';

import RecoverPassword from './RecoverPassword';
it('changes on text input', () => {
    const { getByRole } = render(<RecoverPassword />);
    const emailTextbox = getByRole('textbox', { name: /your email/i });

    userEvent.type(emailTextbox, '[email protected]');

    expect(emailTextbox).toHaveValue('[email protected]');
});

I no longer get the error. Only thing is, I can't say I fully understand why the type of the…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by mgpwilson
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant