I'm putting together a general setups of react typescript and jest+ react testing library. Everything builds and looks fine but when I tried adding rtl and jest the first test i wrote failed. The issue seems to be that the imported render method from rtl fails.
app.test.tsx
import React from 'react';
import { render, screen } from '@testing-library/react';
describe('app component', () => {
it('renders header', () => {
const Test = () => <h1>React</h1>;
render(<Test />);
screen.getByText(/react/i);
screen.debug();
});
});
jest.config.ts
import type { Config } from '@jest/types';
const config: Config.InitialOptions = {
preset: 'ts-jest',
testEnvironment: 'jsdom',
verbose: true,
automock: true,
};
export default config;
