Skip to content
New issue

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

fireEvent does not trigger onLoad event of form component #1171

Closed
komarovalexander opened this issue Jan 29, 2023 · 2 comments
Closed

fireEvent does not trigger onLoad event of form component #1171

komarovalexander opened this issue Jan 29, 2023 · 2 comments

Comments

@komarovalexander
Copy link

komarovalexander commented Jan 29, 2023

  • @testing-library/react version: 13.0.0
  • Testing Framework and version:
  • DOM Environment:

Relevant code or config:

        const CustomForm = () => (
		<form
			onLoad={() => {
				console.log('onLoad'); // this is not triggered
			}}
			data-testid="formmy"
		></form>
	);
	test('SendToCheckButton is disabled if form has unsaved changes', async () => {
		await act(async () => {
			await render(<CustomForm />);
		});
		const form = await screen.findByTestId('formmy');
		act(() => fireEvent.load(form));
	});

What you did:

Hi I'm trying to fire onLoad event on the form but it does not work

it only works inside the addEventListener funtion: form.addEventListener('load', () => console.log('load'));

is there a way to make onLoad work on the form component when calling fireEvent.load?

@komarovalexander komarovalexander changed the title form do not trigger onLoad event fireEvent does not trigger onLoad event on form component Jan 30, 2023
@komarovalexander komarovalexander changed the title fireEvent does not trigger onLoad event on form component fireEvent does not trigger onLoad event of form component Jan 31, 2023
@eps1lon
Copy link
Member

eps1lon commented Feb 15, 2023

Does this work in a browser?

@komarovalexander
Copy link
Author

My bad, I use antd form and this form has onLoad event. Probably I was fired this in a wrong way

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants