Following is my index.js file. There I want to test whether the app is render without crashing.
import ReactDOM from 'react-dom';
import { StrictMode } from 'react';
import App from './App';
import './index.scss';
ReactDOM.render(
<StrictMode>
<App />
</StrictMode>,
document.getElementById('root')
);
The index.test.js file that i have written is given below. Even though the test is passed it has an uncovered line.
/* eslint-env jest */
import ReactDOM from 'react-dom';
import { StrictMode } from 'react';
jest.mock('react-dom', () => ({ render: jest.fn() }));
describe('index.js', () => {
it('renders without crashing', () => {
ReactDOM.render(StrictMode);
expect(ReactDOM.render).toHaveBeenCalledWith(StrictMode);
});
});
Line 1 is noted as uncovered.
import ReactDOM from 'react-dom';
So can you help me to improve the test case for the line.