I am using React Testing Library for first time and it seems very confusing. I am stuck on the error since long. I will be very grateful if someone proposes a solution to this problem
Here is my testfile:
import React from 'react';
import { cleanup, fireEvent, screen } from '@testing-library/react';
import { act } from 'react-dom/test-utils';
import { render } from '../../../test-util';
import EmailEditor from '../../../../components/commonComponents/EmailInput/EmailChip';
const mockFn = jest.fn();
const props={
salutation: '',
signature: '',
emailBody: '',
onChangeEmailBody: () => { },
onFocus: () => { },
onBlur: () => { },
disabled: false,
showSalutation: true,
showSignature: true,
allowVariables: false,
showPersonalize: false,
customParams: [],
recommendImgSize: '',
autoFocus: false,
allowFonts: true
}
describe('Email Editor Test cases', () => {
afterEach(cleanup);
it('Determining the ', async () => {
act(() => {
render(<EmailEditor {...props} /> );
});
const OnclickElement = screen.getByText(/Select Personalization Parameter/i)
expect(OnclickElement).toBeInTheDocument();
});
it('should render the button', async () => {
act(() => {
render(<EmailEditor {...props} /> );
});
const OnclickElement = screen.getByTestId(/custom/i)
expect(OnclickElement).toBeInTheDocument();
});
Here are some of the elements which are associated in index.js
<Header style={{ fontSize: window.innerWidth > MOBILE_WIDTH ? '1.15vw' : 12.15 }}>Select Personalization Parameter</Header>
<CustomToolbar key="customToolbar" show={allowVariables && showPersonalize} uniqueKey={uniqueKey} recommendImgSize={recommendImgSize} allowFonts={allowFonts} data-testid = "custom"/>
Please help me with this.
