We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
those waits don't have any effect , the inputs are already selected with get that would throw if the element was not found
import { createMemoryHistory } from 'history'; import React from 'react'; import { cleanup, render, waitFor, fireEvent } from '@testing-library/react'; import MessageInput from './MessageInput'; describe('MessageInput;', () => { afterEach(cleanup); it('triggers callback on send button click', async () => { const onSendMessage = jest.fn(() => {}); { const { container, getByTestId } = render( <MessageInput onSendMessage={onSendMessage} /> ); const messageInput = getByTestId('message-input'); const sendButton = getByTestId('send-button'); fireEvent.change(messageInput, { target: { value: 'foo' } }); fireEvent.click(sendButton); await waitFor(() => expect(onSendMessage.mock.calls.length).toBe(1)); } }); it('triggers callback on Enter press', async () => { const onSendMessage = jest.fn(() => {}); { const { container, getByTestId } = render( <MessageInput onSendMessage={onSendMessage} /> ); const messageInput = getByTestId('message-input'); fireEvent.change(messageInput, { target: { value: 'foo' } }); fireEvent.keyPress(messageInput, { key: 'Enter', code: 13, charCode: 13, }); await waitFor(() => expect(onSendMessage.mock.calls.length).toBe(1)); } }); });
The text was updated successfully, but these errors were encountered:
I've made the change from the tutorial page itself, I thought it would show a diff or create a PR with a code changed proposed.
basically, both of those tests have await waitFor(() => messageInput);
await waitFor(() => messageInput);
after fireEvent.change - which does nothing
Sorry, something went wrong.
No branches or pull requests
those waits don't have any effect , the inputs are already selected with get that would throw if the element was not found
The text was updated successfully, but these errors were encountered: