@testing-library/react#configure TypeScript Examples

The following examples show how to use @testing-library/react#configure. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Form.test.tsx    From web3uikit with MIT License 6 votes vote down vote up
describe('Form', () => {
    const testTitle = DemoForm.args?.title;
    const testData = DemoForm.args?.data;

    beforeEach(() => render(<DemoForm />));

    it('renders the component', () => {
        const element: HTMLFormElement = screen.getByTestId(formTestID);
        expect(element).not.toBeNull();
    });
    it('renders the title', () => {
        const element: HTMLHeadingElement = screen.getByTestId(FormTestTitleID);
        expect(element).not.toBeNull();
        expect(element?.textContent).toBe(testTitle);
    });
    it('renders the correct amount of inputs from the data', () => {
        configure({ testIdAttribute: 'data-testclass' });
        const elements = screen.getAllByTestId('form-ele');
        expect(elements.length).toBe(testData?.length);
    });
});
Example #2
Source File: Index.test.tsx    From v2 with MIT License 5 votes vote down vote up
configure({ testIdAttribute: 'data-v2' });
Example #3
Source File: setupTests.ts    From pat-frontend-template with Apache License 2.0 5 votes vote down vote up
configure({
  asyncUtilTimeout: 3000,
});