I have two separate components in two different files
ComponentA and ComponentB
I have a button in ComponentB
Now I wish to test that when a particular button in ComponentB is clicked, ComponentA should be rendered as below:
import { render, screen, fireEvent } from '@testing-library/react';
import ComponentA from './ComponentA';
import ComponentB from './ComponentB'
test('Component A Comes up on Click of Component B button', () => {
render(<ComponentB />);
const componentBButton = screen.getByRole('button');
fireEvent.click(componentBButton);
expect(<ComponentA />).toBeInTheDocument(); //This throwing an error that receiver must be HTMLElement or SVGElement
});
Unfortunately, I am getting this error Receiver must be HTMLElement or SVGElement
on the expect(<ComponentA />).toBeInTheDocument();
line
Please, I'm new to testing, how can I solve this? Thank you for your input