I'm trying to test my component if it displays the right value in my h1.
Below is my component that will be tested.
const Title = () => {
return (
<>
<h1 aria-label='Title of the project'>MY RTL PROJECT</h1>
</>
);
};
export default Title;
and here is my test file that tries to check if my component displays "MY RTL PROJECT".
import { render, } from '@testing-library/react';
import Title from '../Title';
describe('Checks the title component', () => {
it('checks the value of the Title component', () => {
const { getByText } = render(<Title />);
const titleValue = getByText('MY RTL PROJECT')
expect(titleValue).toBe('MY RTL PROJECT')
})
})
and here is the error: "messageParent" can only be used inside a worker
● Checks the title component › checks the value of the Title component
expect(received).toBe(expected) // Object.is equality
Expected: "MY RTL PROJECT"
Received: <h1 aria-label="Title of the project">MY RTL PROJECT</h1>